int findMaxLength(vector<int>& nums)
{
int sum=0,res=0;
unordered_map<int,int> table; //sum<>position
table[sum]=1; //initial 0 with position 1
for(int i=0;i<nums.size();i++)
{
sum+=(nums[i]?1:1);
if(table.count(sum))
res=max(res,itable[sum]);
else
table[sum]=i;
}
return res;
}
Easy solution



@ericyoung7001
table is a hash map, and count is a method to check if exists a key. Is it what you want to ask?