-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathset.cpp
More file actions
38 lines (33 loc) · 752 Bytes
/
set.cpp
File metadata and controls
38 lines (33 loc) · 752 Bytes
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
//https://www.hackerrank.com/challenges/cpp-sets/problem?isFullScreen=false
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main() {
set<int> mySet;
long int test_cases, a, b;
cin >> test_cases;
while(test_cases--)
{
cin >> a >> b;
if(a == 1)
{
mySet.insert(b);
}
else if(a==2)
{
mySet.erase(b);
}
else if(a==3)
{
// If the number is preent print Yes, No otherwise
set<int>::iterator itr = mySet.find(b);
if(itr == mySet.end())
cout<<"No"<<endl;
else {
cout<<"Yes"<<endl;
}
}
}
return 0;
}