auto& myKey = myMap.rbegin()->first;
auto& myKey = std::prev(myMap.end())->first;
myMap
is a constant ordered map.
Both of the approaches are with constant complexity. rbegin()
uses reverse iterator, while std::prev
works on bidirectional iterator. Any efficiency difference between them?