Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 1.83 KB

File metadata and controls

39 lines (31 loc) · 1.83 KB

< Previous                  Next >

Related Topics

[Binary Indexed Tree] [Segment Tree] [Array] [Binary Search] [Divide and Conquer] [Ordered Set] [Merge Sort]

Hints

Hint 1 Change the zeros in nums to -1 and create a prefix sum array prefixSum using the new nums.
Hint 2 If prefixSum[i] for any index i in the range 0 <= i < prefixSum.length is positive, that means that there are more ones than zeros in the prefix ending at index i.
Hint 3 If prefixSum[j] > prefixSum[i] for two indexes i and j such that 0 <= i < j < prefixSum.length, that means that there are more ones than zeros in nums in the range [i + 1 : j] (inclusive)