This is the same as "325. Maximum Size Subarray Sum Equals k" (https://leetcode.com/problems/maximum-size-subarray-sum-equals-k/), where zeros are -1, ones are ones, and k is zero. Since in this problem the range of possible sums is [-size...size], we can use an array instead of unordered_map. We can consider size as the zero point, so the array indexes will be [0... 2 * size].

```
int findMaxLength(vector<int>& nums) {
int size = nums.size(), ballance = size, max_len = 0;
int ballances[size * 2 + 1] = {};
for (auto i = 0; i < size; ++i) {
ballance += nums[i] == 0 ? -1 : 1;
if (ballance == size) max_len = i + 1;
else {
if (ballances[ballance] != 0) max_len = max(max_len, i - ballances[ballance] + 1);
else ballances[ballance] = i + 1;
}
}
return max_len;
}
```