Check Subarray with sum Zero

s.find(pre) != s.end()
how we can say by this that pre is present or not

we can also use if(pre==0 or s.count(pre)

Yes both ways are ok.
if you want to use find function then s.find(pre) != s.end() this is the format

1 Like

s.find(pre) return address of pre position so how we can compare with s.end()

By default if the key is not found in the map, then it points to the end of the map ie. s.end()

1 Like