It is notnums
that it is a rule.
For example, givennums = [0, 1, 0, 3, 12]
, after calling your function,nums
should be[1, 3, 12, 0, 0]
.
Note:
You must do this in-place without copying the array.
Minimize the total number of operations.
This is a subarray of sums to k. If there isn't one, return 0 instead.
Note:
The 32-bit signed integer range.
Example 1 :
Givennums = [1, -1, 5, -2, 3], k = 3
,
return4
. (because the subarray[1, -1, 5, -2] sums
to3
and is the longest)
Example 2 :
Givennums = [-2, -1, 2, 1], k = 1
,
return 2. (because the subarray[-1, 2] sums
to1
and is the longest)
Follow Up:
Can you do it in O (n) time?
The input string is valid. Return all possible results.
Note : The input string may contain letters other than the parentheses (and).
Examples:"()())()" -> ["()()()", "(())()"]
"(a)())()" -> ["(a)()()", "(a())()"]
")(" -> [""]
Source: https://habr.com/ru/post/330066/
All Articles