File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < bits/stdc++.h>
2+ using namespace std ;
3+
4+ int main ()
5+ {
6+ // key = value pair
7+ // map store unique keys , in sorted order
8+ map<int , int > mpp;
9+
10+ // everything is sorted
11+ // multimap is key sorted but not unique
12+ // TC - O(1)
13+ // unordered_map is key unique but not sorted
14+
15+ for (const auto &pair : mpp)
16+ {
17+ cout << " Key: " << pair.first << " , Value: " << pair.second << endl;
18+ }
19+
20+ return 0 ;
21+ }
Original file line number Diff line number Diff line change 1+ #include < bits/stdc++.h>
2+ using namespace std ;
3+
4+ int main ()
5+ {
6+ // everything is sorted and unique
7+ set<int > s1;
8+
9+ s1.insert (1 );
10+ s1.insert (10 );
11+ s1.insert (10 ); // <-- will not add
12+ s1.insert (5 );
13+
14+ // everything is sorted
15+ // multiset is sorted but not unique
16+ // TC - O(1)
17+ // unordered_set is unique but not sorted
18+
19+ cout << s1.size ();
20+
21+ return 0 ;
22+ }
You can’t perform that action at this time.
0 commit comments