Last Updated : 10 Apr, 2024
set<int, greater<int>> dst;
dst.insert(20);
dst.insert(30);
dst.insert(10);
dst.insert(50);
dst.insert(10);
    
dst.erase(10);
cout << dst.count(10); 

Predict the output for the above code snippet
(A) 2
(B) 1
(C) 0
(D) None of these


Answer: (C)

Explanation: erase(val): removes the val from the set.
count(val): it returns 1 if the element is present else 0.
In this case 10 is removed hence count(10) returns 0.


Share your thoughts in the comments