-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstl SET.txt
37 lines (37 loc) · 980 Bytes
/
stl SET.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//https://www.hackerrank.com/challenges/cpp-sets/problem
/*Declaration:
set<int>s; //Creates a set of integers.
Size:
int length=s.size(); //Gives the size of the set.
Insert:
s.insert(x); //Inserts an integer x into the set s.
Erasing an element:
s.erase(val); //Erases an integer val from the set s.
Finding an element:
set<int>::iterator itr=s.find(val); //Gives the iterator to the element val if it is found otherwise returns s.end() .
Ex: set<int>::iterator itr=s.find(100); //If 100 is not present then it==s.end().*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
set <int> s;
while(t--)
{
int x,y;
cin>>y>>x;
if(y==1)
s.insert(x);
else if(y==2)
s.erase(x);
else
{
if(s.end()==s.find(x))
cout<<"No"<<endl;
else
cout<<"Yes"<<endl;
}
}
return 0;
}