forked from createme24/C-STL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsets.cpp
More file actions
34 lines (33 loc) · 706 Bytes
/
sets.cpp
File metadata and controls
34 lines (33 loc) · 706 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
//an associative container
//every elemnt is unique
//elemnts are stored in sorted order
//all opertn can be done in logn time
//it uses tree
//tree->red black tree(height can be h and h+1)(less frestricted)
//element address else end address
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
set<int>s;
//set<int>s(arr,arr+n);
for(int i=0;i<n;i++){
s.insert(arr[i]);
}
int t;
cin>>t;
s.erase(t);
int k;
cin>>k;
auto it1=s.find(k);
cout<<*it1<<endl;
cout<<"set is";
for(auto it:s){
cout<<it<<endl;
}
}