반응형
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() {
set<int> s;
set<int>::iterator itr;
int num, q, val;
cin >> num;
for (int i = 0; i < num; i++) {
cin >> q >> val;
if (q == 1) s.insert(val);
else if (q == 2) s.erase(val);
else {
itr = s.find(val);
if (itr == s.end()) cout << "No" << endl;
else cout << "Yes" << endl;
}
}
return 0;
}
Reference
반응형
'Training > HackerRank' 카테고리의 다른 글
[C++][STL] Maps-STL (0) | 2021.11.21 |
---|---|
[C++][STL] Lower Bound-STL (0) | 2021.08.08 |
[C++][Introduction] Variable Sized Arrays (0) | 2021.08.07 |
[C++][STL] Vector-Erase (0) | 2021.08.07 |
[C++][Classes] Class (0) | 2021.08.07 |