Longest Zero Sublist Sum
Given a list of integers nums
, which contains either -1
or 1
, return the length of the longest sublist that sums to 0
.
Constraints
n ≤ 100,000
wheren
is the length ofnums
.
https://binarysearch.com/problems/Longest-Zero-Sublist-Sum
Examples
Example 1
Input
- nums =
[1, 1, 1, 1, -1, -1, 1, -1]
Output
- answer =
6
Explanation
The longest sublist that sums to 0 is [1, 1, -1, -1, 1, -1] which has length 6.
Leave a comment