Created
May 7, 2019 15:50
-
-
Save lazycipher/bcd6ed826edbaf151fa4cba09e0acea1 to your computer and use it in GitHub Desktop.
HackerRank C++ Sets-STL Problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <cstdio> | |
#include <vector> | |
#include <iostream> | |
#include <set> | |
#include <algorithm> | |
using namespace std; | |
int main() { | |
set<int> s; | |
int q; | |
cin>>q; | |
while(q){ | |
int operationType, x; | |
cin>>operationType>>x; | |
switch(operationType){ | |
case 1: s.insert(x); | |
break; | |
case 2: s.erase(x); | |
break; | |
case 3: | |
set<int>::iterator itr = s.find(x); | |
if(itr==s.end()){ | |
cout<<"No"<<endl; | |
}else{ | |
cout<<"Yes"<<endl; | |
} | |
} | |
q--; | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment