Longest Zero Sum Subarray

HASH TABLE
ARRAY

Problem

Given an array nums of integers, find the longest contiguous subarray that sums to zero.

Return the starting and ending indices of this subarray. If there are multiple answers, return the indices of any one of them.

Examples

longestZeroSumSubarray([20, 42, 1, 1, -1, 5, -5]) // returns [3, 6] // [1, -1, 5, -5] is the longest subarray that sums up to zero
Loading...