For example, given:
S:
"barfoothefoobarman"L:
["foo", "bar"]
You should return the indices:
[0,9].(order does not matter).
"barfoothefoobarman"["foo", "bar"]
[0,9]."great":
great
/ \
gr eat
/ \ / \
g r e at
/ \
a t
To scramble the string, we may choose any non-leaf node and swap its two children.
"gr" and swap its two children, it produces a scrambled string "rgeat".
rgeat
/ \
rg eat
/ \ / \
r g e at
/ \
a t
We say that "rgeat" is a scrambled string of "great".
"eat" and "at", it produces a scrambled string "rgtae".
rgtae
/ \
rg tae
/ \ / \
r g ta e
/ \
t a
We say that "rgtae" is a scrambled string of "great".
"aabcc","dbbca",
"aadbbcbcac", return true."aadbbbaccc", return false.1 and 0 respectively in the grid.[ [0,0,0], [0,1,0], [0,0,0] ]The total number of unique paths is
2.
1
/ \
2 3
Return 6. For example, given array S = {1 0 -1 0 -2 2}, and target = 0.
A solution set is:
(-1, 0, 0, 1)
(-2, -1, 1, 2)
(-2, 0, 0, 2)
For example, given array S = {-1 2 1 -4}, and target = 1.
The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).
For example, given array S = {-1 0 1 2 -1 -4},
A solution set is:
(-1, 0, 1)
(-1, -1, 2)