-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path68Set_STL.cpp
More file actions
33 lines (29 loc) · 865 Bytes
/
68Set_STL.cpp
File metadata and controls
33 lines (29 loc) · 865 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
#include <iostream>
#include <iterator>
#include <set>
using namespace std;
/*
Time Complexity : O(log(n))
Time Complexity in Unordered_set : O(1)
Unordered_set doesn't have a lot of valid data types
*/
void print(set<char> &s){
for(char value : s){
cout<<value<<" ";
}
}
int main(){
set<char> s1;
string name; cin>>name;
for(char ch : name){
s1.insert(ch);
}
print(s1);
multiset<string> s; //O(log(n));
// allow to store multiple values in a set
//s.find() will return the iterator of first known element you have to find
//Note: if you want to use s.erase() and only have to delete only one value of two same value
// then use s.erase(it) instead of s.erase("abc"), cause it will delete all values.
// it can be found be s.find()
return 0;
}