Balanced Binary Run
bits contains only 0s and 1s. Return the length of the longest contiguous subarray with the same number of 0s and 1s.
Examples
EXAMPLE WALKTHROUGHpair
A guided view of the published example, not a trace of your code.
INPUT
[[0,1]]TASKbalanced_binary_run()
EXPECTED OUTPUT
2Start with the input values shown in this example.
Example 1 of 3
Input: bits = [0,1]
Output: 2
Explanation: pair
Input: bits = [0,1,0]
Output: 2
Explanation: odd length
Input: bits = [0,0,1,0,0,0,1,1]
Output: 6
Explanation: longer
Hint 1
Treat 0 as -1. Then you want the longest subarray summing to 0.