We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */set<int>s;intQ;cin>>Q;for(inti=0;i<Q;i++){pair<int,int>query;cin>>query.first>>query.second;intx=query.first;inty=query.second;if(x==1){s.insert(y);}elseif(x==2){s.erase(y);}elseif(x==3){set<int>::iteratorit=s.find(y);it==s.end()?cout<<"No\n":cout<<"Yes\n";}}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Here is Sets-STL problem solution in C++ - https://programmingoneonone.com/hackerrank-sets-stl-solution-in-cpp.html
//M.Kohaku
include
using namespace std;
int main(){ sets; int n; cin >> n; for(int i=0;i p; cin >> p.first >> p.second; int x = p.first; int y = p.second; if(x==1){ s.insert(y); } else if(x==2){ s.erase(y); } else if(x==3){ if(s.count(y)) cout << "Yes" << endl; else cout << "No" << endl; } } }
My solution:
My C++ code