Search
⌘K

Leetcode 525. Contiguous Array

Find the maximum length of a contiguous subarray in a binary array that contains an equal number of 0s and 1s. This is solved by using a running sum (treat 0 as -1) and a hash map to record first occurrences of each cumulative sum to find longest zero-sum spans in O(n) time for n up to 1e5.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Your account is free and you can post anonymously if you choose.