Insertion and Deletion of Multiset Elements while Traversing through for loop using iterators
Here, I am performing erase operations and an insert operation on the multiset while traversing through the multiset. The Code that I have written is: #include <bits/stdc++.h> using namespace std; int main(){ multiset<int> ms; ms.insert(6); ms.insert(7); ms.insert(8); ms.insert(9); ms.insert(10); for(auto it = ms.begin();it != ms.end();it++){ cout << *it << endl; ms.erase(it); if(*it == 6){ ms.insert(4);… Read More Insertion and Deletion of Multiset Elements while Traversing through for loop using iterators