Actieve werkgever
Find the largest subarray with 0 sum answer
Anoniem
To find the largest subarray with sum zero, I use a prefix sum and a hash map. I keep a running sum while iterating through the array. If the sum is zero, the subarray from the start to the current index has zero sum, so I update the max length. If the sum repeats, it means the subarray between the previous index and current index sums to zero, and I update the max length accordingly. This runs in O(n) time with O(n) space.