Skip to content

Instantly share code, notes, and snippets.

@lazycipher
Created May 7, 2019 15:50
Show Gist options
  • Save lazycipher/bcd6ed826edbaf151fa4cba09e0acea1 to your computer and use it in GitHub Desktop.
Save lazycipher/bcd6ed826edbaf151fa4cba09e0acea1 to your computer and use it in GitHub Desktop.
HackerRank C++ Sets-STL Problem
#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