I have a map as below :
std::map< std::string ,int> mapobj;
mapobj[\"one\"] = 1;
mapobj[\"two\"] = 2;
mapobj[\"three\"] =3 ;
how to g
how to get key when input is value
First, there is no guarantee that value is unique. I realize that you are saying it is unique. Still, conceptually speaking, this is something to keep in mind when looking at the problem.
Second, std::map
is not sorted by value. Hence, the most efficient algorithm to look for a value will be O(N)
on an average.