Find the longest contiguous part of the binary array nums that contains exactly as many zeros as ones. Return its length, or zero when no nonempty subarray qualifies.
Example 1:
Input: nums = [0,1,1,0,1,0]
Output: 6Explanation: The entire array contains three zeros and three ones, so all six entries form a balanced subarray.
Example 2:
Input: nums = [0,0,1]
Output: 2Explanation: The last two entries form [0,1], with one zero and one one. The full array is not balanced.
Example 3:
Input: nums = [1]
Output: 0Explanation: The array contains no zero, so it has no nonempty subarray with equal counts of zeros and ones.
Constraints:
1 <= nums.length <= 1000000 <= nums[i] <= 1