The problem. Given an array nums that contains only 0s and 1s, return the length of the longest subarray with as many 0s as 1s. If there is none, return 0. (On LeetCode this is *Contiguous Array*.)
nums = [1, 0, 1, 1, 1, 0, 0] -> 6 ([0, 1, 1, 1, 0, 0])
nums = [0, 0, 1, 1, 0] -> 4 ([0, 0, 1, 1] or [0, 1, 1, 0])
nums = [1, 1, 1] -> 0Free account
Sign up to read the rest of this lesson: 7 more sections, 2 drawings, a dry-run simulator and code in JavaScript, Python, Java and C++.
Still to come