I had the habit of using  operator to access elements of a map. For example, if we have
map<int, int> myMap, to get the element corresponding to 10, we can use
myMap. This is perfectly ok as long as we have an element corresponding to 10. But, what if we don’t have one corresponding to 10?
There lies the problem. In this situation, myMap is already added with a default elemnent corresponding to 10 ( operator provides no facility to validate if an element exists) and in the above situation, it is 0. As a result, a new (unwanted) element is added to the map (we can see that the size of map has been incremented by 1).
So a better alternative is to use the find() function associated with map. It does not add an element and if the element is not found, it will return map::end().
The example given below illustrates this.