what is the significance of s.find(pre)!=s.end()
please tell me significance of this
Not understand line of code
By that line you are checking if same prefix sum has been found earlier . It means that the subarray starting from that index till the current index will have a subarray sum as 0.
Dry run with an example case to understand well
why we write !=s.end() as s.find() is a boolean fuction, can we write as s.find(pre)==0?
using s.find(), if search element is not found, then it will return an iterator pointing to next position of the last element ie. s.end()
This is why we compare it with s.end()
We cannot write s.find()==0 because find function does not return a boolean or an integer value.
It returns an iterator or a constant iterator that refers to the position where the key is present in the map. If the key is not present in the map container, it returns an iterator or a constant iterator which refers to map.end().