map<int, int> mp;
mp.insert(pair <int, int> (1, 40));
mp.insert(pair <int, int> (2, 30));
mp.insert(pair <int, int> (3, 60));
mp.insert(pair <int, int> (4, 20));
mp.insert(pair <int, int> (5, 50));
mp.insert(pair <int, int> (6, 50));
mp.insert(pair <int, int> (7, 10));
cout << mp.lower_bound(5)->first;
Possible outcome for the above code snippet
(A) 4
(B) 5
(C) 6
(D) None of these
Answer: (B)
Explanation: lower_bound(const g) – Returns an iterator to the first element that is equivalent to mapped value with key value ‘g’ or definitely will not go before the element with key value ‘g’ in the map
Quiz of this Question
Share your thoughts in the comments
Please Login to comment...