You are viewing a single comment's thread. Return to all comments →
You don't need to declare an iterator object just to check if the value exists. And switch looks more suitable here than lot of if-then...
int main() { int iCount; set<int> ss; cin >> iCount; for (int i=0; i<iCount; ++i){ int type, query; cin >> type >> query; switch (type){ case 1: ss.insert(query); break; case 2: ss.erase(query); break; case 3: cout << (ss.find(query) == ss.end() ? "No" : "Yes") << endl; break; } } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Sets-STL
You are viewing a single comment's thread. Return to all comments →
You don't need to declare an iterator object just to check if the value exists. And switch looks more suitable here than lot of if-then...