nums (values may be negative) and a number target. A run is a non-empty stretch of consecutive elements of the array.
Return the length of the longest run whose elements sum to target, or 0 if there is no such run.nums=[2, -1, 3, 1, -2], target=2 → 3
The runs [2], [-1, 3] and [3, 1, -2] all sum to 2. The longest is [3, 1, -2], of length 3.
nums=[4, 4], target=3 → 0
No run sums to 3, so the answer is 0.
nums.length ≤ 2·10⁵nums[i] ≤ 10⁴target ≤ 10⁹nums=[2, -1, 3, 1, -2], target=2
3
Run checks the first 3 tests in your browser. Submit checks all 117 tests on the server, hidden ones included.