in the solution, it is implemented by storing prefix sum values in set and checking for 0 or duplicate.
snippet:
for(i=0;i<n;i++0{
prefix += arr[i]
if( prefix ==0 or s.find(prefix) != s.end() )
return true;
else
s.insert(prefix);
}
my question:
in the first iteration of the loop, set would be empty then how does s.find() work in that case?
what is s.end() for an empty set?
shouldn’t we insert the prefix before the if condition?