Blame view

SearchingSortingandBasicDataStructures/Set/Problem1/Sets.cpp 606 Bytes
8ecd5fda8   Ronaldo Silva   Update project.
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
  //
  // Created by ronal on 2/25/2023.
  // Problem Description Link.
  // https://www.hackerrank.com/challenges/cpp-sets/problem
  
  #include <bits/stdc++.h>
  using namespace std;
  
  
  int main() {
      int Q, y, x;
      set<int> S;
      cin >> Q;
      for(int i = 0; i < Q; i++){
          cin >> y >> x;
          if(y == 1){
              S.insert(x);
          }else if(y == 2){
              S.erase(x);
          }else if(y == 3){
              auto it = S.find(x);
              if(it != S.end()){
                  cout << "Yes
  ";
              }else{
                  cout << "No
  ";
              }
          }
      }
      return 0;
  }