題目

題目連結:https://leetcode.com/problems/intersection-of-two-linked-lists/

給定兩個 Linked list,找出其交點。若沒有交點則回傳 null

範例說明

Example 1:

1
2
3
Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8,4,5], skipA = 2, skipB = 3
Output: Reference of the node with value = 8
Input Explanation: The intersected node's value is 8 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as [4,1,8,4,5]. From the head of B, it reads as [5,6,1,8,4,5]. There are 2 nodes before the intersected node in A; There are 3 nodes before the intersected node in B.

閱讀全文 »

題目

題目連結:https://leetcode.com/problems/middle-of-the-linked-list/

給一個 Linked list,回傳其中間的點。如果有兩個中間的點,則回傳後面的那個。

範例說明

Example 1:

1
2
3
4
5
Input: [1,2,3,4,5]
Output: Node 3 from this list (Serialization: [3,4,5])
The returned node has value 3. (The judge's serialization of this node is [3,4,5]).
Note that we returned a ListNode object ans, such that:
ans.val = 3, ans.next.val = 4, ans.next.next.val = 5, and ans.next.next.next = NULL.
閱讀全文 »

目標

使用 operator-sdk 建立一個 CustomResourceDefinition,類似於 ReplicaSet 的功能,在這裡筆者將他稱為 PodSet。

PodSet 可以自動的創建 Replicas 的數量個 Pods,並且在 Pods 被新增、刪除,或是 PodSet 的 Spec 被修改時自動增減 Pods 的數量。

先附上 PodSet 的 Spec:

1
2
3
4
5
6
7
apiVersion: k8stest.justin0u0.com/v1alpha1
kind: PodSet
metadata:
name: podset-sample
spec:
# Add fields here
replicas: 2

程式碼的部分在:https://github.com/justin0u0/podset-operator

閱讀全文 »

題目

題目連結:https://leetcode.com/problems/distinct-subsequences/

給定兩字串 s, t,求出 s 字串中有多少的子序列(subsequence)等於 t

範例說明

Example 1:

1
2
3
4
5
6
7
Input: s = "rabbbit", t = "rabbit"
Output: 3
Explanation:
As shown below, there are 3 ways you can generate "rabbit" from S.
rabbbit
rabbbit
rabbbit

Example 2:

1
2
3
4
5
6
7
8
9
Input: s = "babgbag", t = "bag"
Output: 5
Explanation:
As shown below, there are 5 ways you can generate "bag" from S.
babgbag
babgbag
babgbag
babgbag
babgbag
閱讀全文 »

題目

題目連結:https://leetcode.com/problems/interleaving-string/

給定字串 s1, s2 以及 s3,問是否能將 s1, s2 交織(interleaving) 而成 s3

若字串兩字串 s, t,其中 s = s1 + s2 + ... + sn, t = t1 + t2 + ... + tm|n - m| < 1
s, t 的交織 (interleaving) 可以是 s1 + t1 + s2 + t2 + ... 或是 t1 + s1 + t2 + s2 + ...

範例說明

Example 1:

1
2
Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"
Output: true
閱讀全文 »
0%