Longest run summing to zero
Write longest_zero_run(nums) that returns the length of the longest run of
consecutive items whose sum is zero, or 0 if there is none.
longest_zero_run([1, -1, 3, 2, -2, -3, 3]) -> 6 ([1, -1, 3, 2, -2, -3])
longest_zero_run([1, 2, 3]) -> 0
longest_zero_run([0, 0, 0]) -> 3
The point is to practise prefix sums with a dictionary of first occurrences: two equal prefix sums bracket a zero-sum run.
def longest_zero_run(nums):
...