You are given an array of integers representing the load added or removed at each stop of a delivery route, in order. The array can contain positive numbers (loaded), negative numbers (unloaded), and zeros (no change). A contiguous subarray is called a balanced window if the sum of its elements is exactly zero. Return the length of the LONGEST balanced window. If no such window exists, return 0. Note the array can contain any mix of positive, negative and zero values (this is not the usual all-positive sliding window case), so you need an approach that handles that correctly and still runs efficiently.
No one has cracked it yet. Be the first.