Last Updated : 10 Apr, 2024
multiset<int, greater<int>> mst;
mst.insert(20);
mst.insert(30);
mst.insert(10);
mst.insert(50);
mst.insert(10);
    
mst.erase(mst.begin(), mst.find(10));
multiset<int> :: iterator itr;
for(itr = mst.begin(); itr != mst.end(); itr++)
   cout << *itr << \" \";
cout << endl;
cout << mst.count(10); 

Possible outcome for the above code snippet
(A) 10 10
2
(B) 10
1
(C) 50 30 20 10 10
2
(D) None of these


Answer: (A)

Explanation: erase(val): removes val from the multiset
mst.erase(mst.begin(), mst.find(10)); – remove all elements up to element with value 10 in mst.


Share your thoughts in the comments