A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.
Return a deep copy of the list.
0-9
only, each root-to-leaf path could represent a number.1->2->3
which represents the number 123
.1 / \ 2 3
1->2
represents the number 12
.1->3
represents the number 13
.25
.null
.1->4->3->2->5->2
and x = 3,1->2->2->4->3->5
.1->2->3->3->4->4->5
, return 1->2->5
.1->1->1->2->3
, return 2->3
.sum = 22
,5 / \ 4 8 / / \ 11 13 4 / \ \ 7 2 1return true, as there exist a root-to-leaf path
5->4->11->2
which sum is 22.sum = 22
,5 / \ 4 8 / / \ 11 13 4 / \ / \ 7 2 5 1return
[ [5,4,11,2], [5,8,4,5] ]
1->1->2
, return 1->2
.1->1->2->3->3
, return 1->2->3
.{3,9,20,#,#,15,7}
,3 / \ 9 20 / \ 15 7return its zigzag level order traversal as:
[ [3], [20,9], [15,7] ]
{3,9,20,#,#,15,7}
,3 / \ 9 20 / \ 15 7return its bottom-up level order traversal as:
[ [15,7] [9,20], [3], ]
{3,9,20,#,#,15,7}
,3 / \ 9 20 / \ 15 7return its level order traversal as:
[ [3], [9,20], [15,7] ]
1 / \ 2 5 / \ \ 3 4 6
1 / \ 2 3
6
.1 / \ 2 5 / \ \ 3 4 6
1 \ 2 \ 3 \ 4 \ 5 \ 6
10,1,2,7,6,1,5
and target 8
, [1, 7]
[1, 2, 5]
[2, 6]
[1, 1, 6]
2,3,6,7
and target 7
, [7]
[2, 2, 3]
Input:Digit string "23" Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
[1,1,2]
have the following unique permutations:[1,1,2]
, [1,2,1]
, and [2,1,1]
.[1,2,3]
have the following permutations:[1,2,3]
, [1,3,2]
, [2,1,3]
, [2,3,1]
, [3,1,2]
, and [3,2,1]
.[1,2,2]
, a solution is:[ [2], [1], [1,2,2], [2,2], [1,2], [] ]
[1,2,3]
, a solution is:[ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], [] ]
[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ]