-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathcpp-sets.cpp
More file actions
32 lines (28 loc) · 733 Bytes
/
cpp-sets.cpp
File metadata and controls
32 lines (28 loc) · 733 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
// Sets-STL
// Learn about the set container. Given a problem with 3 queries, try to answer the queries using the set container.
//
// https://www.hackerrank.com/challenges/cpp-sets/problem
//
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
set<int> s;
int q, op, i;
cin >> q;
while (q-- != 0)
{
cin >> op >> i;
switch (op) {
case 1: s.insert(i); break;
case 2: s.erase(i); break;
case 3: cout << (s.count(i) != 0 ? "Yes" : "No") << endl;
}
}
return 0;
}