Interview Question
1. loop through the map using iterator
2. look at each value and compare to the search value
3. delete the key-value pair in the map that matches the search value
4. break out of loop immediately
5. put the search value in the map using a new / updated key
Time efficiency is O(n) or better. If there is faster algorithm, please reply to this.
How can I sort a map by its .second parameter.Write the C++ code.
- Posch December 27, 2010