set stl Question 9

Last Updated :
Discuss
Comments

What is the output of the following code?

#include <iostream>
#include <set>

int main() {
  std::multiset<int> s {1, 2, 3, 3, 3, 4, 4, 5};
  s.erase(3);
  for (auto it = s.begin(); it != s.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
  return 0;
}

1 2 3 4 5

1 2 4 4 5

1 2 4 5

2 4 5

Share your thoughts in the comments