I am confused which is more efficient?
As we can access map directly, why do we need to use find?
I just need to know which way is more efficient.
The [] operator in map is not constant it is logarithmic. Most of the books stress on this fact and point out it is a bit misleading. So both find and [] operator are with the same complexity.
Please note that the [] operator will create the entry even if it does not exist while find will return end() in that case.