all about map , multimap
source link: https://codeforces.com/blog/entry/109338?f0a28=1
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
all about map , multimap
****************************************MAP*****************************************
*** Why are sets and maps useful C++? The difference is set is used to store only keys while map is used to store key value pairs. For example consider in the problem of printing sorted distinct elements, we use set as there is value needed for a key. While if we change the problem to print frequencies of distinct sorted elements, we use map. *** Which tree is used by map in C++? self-balancing Binary Tree The internal implementation of map is self-balancing Binary Tree
https://www.simplilearn.com/tutorials/cpp-tutorial/cpp-map#overview_of_c
we can use map ,, insted fo pair ,, because of ,, it sorted ,, according to key
/* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); int t , ini; cin >> t; string aa ; map<string , int> kk; for(int i = 0 ; i < t ; i++) { cin >> aa >> ini; kk.insert({aa , ini}); } for(auto u : kk) cout << u.first << " " << u.second << endl;
return 0;
out put ::::: (1)
5 asdadasd 1 sadsdasd 2 dasdasdasd 5 sadasdasdasd 12121 sadasdasdasdas 7
asdadasd 1 dasdasdasd 5 sadasdasdasd 12121 sadasdasdasdas 7 sadsdasd 2
out put ::::: (2) 5 sadasdasd 1 sadasdasdas 4 sdasdasd 3 sadasdasd 1 sadasdasdas 22222222
sadasdasd 1 sadasdasdas 4 /// value is not replased ???????????????????? sdasdasd 3 /// value is not replased ????????????????????
*** /* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); map<string , int> aa; aa["sayem"] = 10; aa["rony"] = 111; aa["mia"] = 333; aa["tasnim"] = 75756; aa["tufassis"] = 909898; aa["nuzum"] = 4444444444; aa["sayem"] = 3333333; for(auto u : aa) cout << u.first << " " << u.second << endl;
return 0;
out put ::::: (1)
mia 333 nuzum 149477148 rony 111 sayem 3333333 /// value are repalsed ????????????????????????????????????????? tasnim 75756 tufassis 909898
/* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); map<int , bool> vis; vector aa = {1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 , 9 ,10 ,1 , 1 , 1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 , 9 ,10 ,1 , 1 }; for(auto u : aa) vis[u] = 1; /// if we use ,, vis[u]++; than we found frequency of corresponding key ... but now a time ,, we are not use increment (vis[u]++) ,, for(auto u : vis)//// we just use (vis[u] = 1) ,, which is just told us that ,, cout << u.first << " " << u.second << endl;///is this key is visited or not ,, but .. main thing is ,, all map element of (key) are always visiter...
return 0;
out put ::::: (1)
1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1
/* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); map<string , int>aa; int t; cin >> t; for(int i = 0 ; i <= t ; i++) { string bb; int s; cin >> bb >> s; aa[bb] = s; } for(auto u : aa) cout << u.first << " " << u.second << endl;
return 0;
out put ::::: (1)
5 sdasdasda 23 dfasdas 2333 xdasdffsdf 2323 sdasdasda 23 dfasdas 2333 xdasdffsdf 2323
dfasdas 2333 sdasdasda 23 xdasdffsdf 2323
*** count how many string comes twise
/* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); int t; cin >> t; while(t--) { int s; cin >> s; vector aa(s); map<string , int> kk; for(int i = 0 ; i < s ; i++) { cin >> aa[i]; kk[aa[i]]++; } int cnt = 0; for(auto u : kk) { cout <<u.first << " " << u.second << endl; if(u.second == 2) cnt++; }
cout << cnt << endl; } return 0;
out put ::::: (1)
3 Geeks For Geeks 8 Tom, Jerry, Thomas, Tom, Jerry,Courage, Tom, Courage // comma is also a part of string
For 1 Geeks 2 1
Courage 1 Courage, 1 Jerry, 2 Thomas, 1 Tom, 3 1
*** sentence to vector of string
char a; string aa; cin >> a; getline(cin , aa);/// we use getline ,, because of (if we take maltiple sentence than some problem is created like{ last word or last sentence is no store (main thing is last string is not stored ,, so ,, last word is not printed if we want to print the vector of string)}) aa = a + aa; string ini; vector<string> kk; for(auto u : aa) { ini = ini + u; if(isspace(u)) { kk.push_back(ini); ini.clear(); } } for(auto u : kk) cout << u << endl;
Word with maximum frequency ( Geeks for Geeks ) [Amazon interview question]
/* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); char a; string aa; cin >> a; getline(cin , aa);/// we use getline ,, because of (if we take maltiple sentence than some problem is created like{ last word or last sentence is no store (main thing is last string is not stored ,, so ,, last word is not printed if we want to print the vector of string)})
aa = a + aa; string ini; vector<string> kk; for(auto u : aa) { ini = ini + u; if(isspace(u)) { kk.push_back(ini); ini.clear(); } } map<string , int> cnt; int maxfreaq = 0; for(auto u : kk) { cnt[u]++; maxfreaq = max(cnt[u] , maxfreaq); } string ans ; for(auto u : kk)/// i ting u take the first value of map ;; { if(maxfreaq == cnt[u]) { ans = u; break; } } cout << ans << " " << maxfreaq << endl; return 0;
out put ::::: (1)
the devil in the sky
************ //// if kk is just a map for(auto u : kk)/// i ting u take the key of map ;; { cout << u << endl;/// u carry only key ;; }
5) C — Good Sequence ( Atcoder )
/* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); int t; cin >> t; int ini; map<int , int> aa; for(int i = 0 ; i < t ; i++) { cin >> ini; aa[ini]++; } int sum = 0; for(auto u : aa) { if(u.second >= u.first) sum = sum + u.second — u.first; else sum = sum + u.second; } cout << sum << endl; return 0; }
out put ::::: (1)
5 2 4 1 4 2
**************** A. Tom Riddle's Diary
/* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); int t; cin >> t; map<string , int> aa; string ini; for(int i = 0 ; i < t ; i++) { cin >> ini; if(aa[ini] == 0) { cout << "NO" << endl; aa[ini] = 1; } else { cout << "YES" << endl; } } return 0; }
input
6 tom lucius ginny harry ginny harry
output
NO NO NO NO YES YES
************************* C. Registration system
/* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); int t; cin >> t; map<string , int> aa; string ini; for(int i = 0 ; i < t ; i++) { cin >> ini; aa[ini]++; if(aa[ini] == 1) cout << "OK" << endl; else cout << ini << aa[ini] — 1 << endl; } return 0; }
input
4 abacaba acaba abacaba acab
output
OK OK abacaba1 OK
input
6 first first second second third third output OK first1 OK second1 OK third1
B. Radio Station
/* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); int t , s; cin >> t >> s; string a ,b; map<string , string> aa; for(int i = 0 ; i < t ; i++) { cin >> a >> b; aa[b] = a; } for(int i = 0 ; i < s ; i++) { cin >> a >> b; cout << a << " " << b << " #"; b.pop_back(); cout << aa[b] << endl; }
return 0;
input
2 2 main 192.168.0.2 replica 192.168.0.1 block 192.168.0.1; proxy 192.168.0.2;
output
block 192.168.0.1; #replica proxy 192.168.0.2; #main
input
3 5 google 8.8.8.8 codeforces 212.193.33.27 server 138.197.64.57 redirect 138.197.64.57; block 8.8.8.8; cf 212.193.33.27; unblock 8.8.8.8; check 138.197.64.57;
output
redirect 138.197.64.57; #server block 8.8.8.8; #google cf 212.193.33.27; #codeforces unblock 8.8.8.8; #google check 138.197.64.57; #server
******************** RPLD — Database #ad-hoc-1
/* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); int t; cin >> t; for(int i = 0 ; i < t ; i++) { int a ,b ; cin >> a >> b; int k , l; map<pair<int , int> , int> mp; for(int j = 0 ; j < b ; j++) { cin >> k >> l; mp[{k , l}]++; } cout << "Scenario #" << i + 1 << ": "; if(b == mp.size()) cout << "possible" << endl; else cout << "impossible" << endl; } return 0; }
INPUT: 2 2 4 1 6102 1 6103 2 6102 2 6103
2 4 1 6102 1 6102 2 6102 2 6103
Output: Scenario #1: possible Scenario #2: impossible
**************************************** ++++++ wrong submission
+++++++++++++++++++++++++13.L — 13- Map — 1 — Standard Template Library ( STL ) — Competitive Programming ( Bangla ) — C++
========>>>>> mp.insert({key / index , velue});
/* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); int t; cin >> t; map<int , int> mp; int a , b; for(int i = 0 ; i < t ; i++) { cin >> a >> b; mp.insert({a , b}); /////////// we can use ... mp[a] = b; ..... this line ... which is as well as insertion } for(auto u : mp) cout << u.first << " " << u.second << endl;
return 0;
OUTPUT :::: 1
5 1 2 1 2 1 2 3 4 5 6
1 2 3 4 5 6
***********====>>> using of mp.at(index or key) and mp[index or key] /// bouth are work in same /// using them we can .. change any index value or replace index value
/* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); map<int , int> mp; mp[1] = 100; mp[2] = 200; mp[3] = 300; mp[4] = 400; mp[2] = mp[2] + 4000; //// if we use same index for maltiple time than only last insertion is stay for last value // mp.at(1) = 100; // mp.at(2) = 200; // mp.at(3) = 300; // mp.at(4) = 400; // mp.at(2) = mp[2] + 4000; // mp.insert({1 , 100}); // mp.insert({2 , 200}); // mp.insert({3 , 300}); // mp.insert({4 , 400}); // mp.insert({2 , 200000}); /// but value updating is not work in using (in insertion process) for(auto u : mp) cout << u.first << " " << u.second << endl;
/////???? insted of using for each loop ,, we can use iterator for map ,, and ,, using this ,, we can also .. print first ans second velue of map
// map<int , int>::iterator it; // for(it = mp.begin() ; it != mp.end() ; it++) // cout << it->first << " " << it->second << endl; return 0; }
OUTPUT :::::: 1
1 100 2 4200 3 300 4 400
alter vative .. but not workable for value replacement
/* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); map<int , int> mp; // mp[1] = 100; // mp[2] = 200; // mp[3] = 300; // mp[4] = 400; // mp[2] = mp[2] + 4000; //// if we use same index for maltiple time than only last insertion is stay for last value // mp.at(1) = 100; // mp.at(2) = 200; // mp.at(3) = 300; // mp.at(4) = 400; // mp.at(2) = mp[2] + 4000; mp.insert({1 , 100}); mp.insert({2 , 200}); mp.insert({3 , 300}); mp.insert({4 , 400}); mp.insert({2 , 200000}); /// but value updating is not work in using (in insertion process) for(auto u : mp) cout << u.first << " " << u.second << endl;
return 0;
OUTPUT :::: 2
1 100 2 200 3 300 4 400
++++++++++++++++++++++++++++++++++++++++++++++++++++ 14.L — 14- Map — 2 — Standard Template Library ( STL ) — Competitive Programming ( Bangla ) — C++
/* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); map<int , int> mp , mpp;
mp[10] = 100; mp[20] = 200; mp[30] = 300; mp[40] = 400; mp[50] = 500; mpp = mp ; ///??? using assignment operator ,, easily we ,, copy a map ,, watch 74 number line ,, there i print a map of mpp using for each loop ///??? lower_bound /// if lower_bound is existed than its return its own value ,, if not ,, its return nearest greatest value ,, else ,, it is greater than max value it return end() pointer value or garbage valu cout << "LOWER_BOUND" << endl; auto itt = mp.lower_bound(15); cout << (*itt).first << " " << (*itt).second << endl; itt = mp.lower_bound(10); cout << (*itt).first << " " << (*itt).second << endl; itt = mp.lower_bound(50); cout << (*itt).first << " " << (*itt).second << endl; itt = mp.lower_bound(55); /// 55 number key is no existed in map of mp so cout << (*itt).first << " " << (*itt).second << endl; /// get garbage value nothing more /// if upper_bound is existed than its return its next pointer ,, if not ,, its return nearest greatest pointer ,, else ,, it is greater than max value ** or (it is owner of max value )than it return end() pointer value or garbage value cout << "upper_BOUND" << endl; itt = mp.upper_bound(15); cout << (*itt).first << " " << (*itt).second << endl; itt = mp.upper_bound(10); cout << (*itt).first << " " << (*itt).second << endl; itt = mp.upper_bound(50); cout << (*itt).first << " " << (*itt).second << endl; itt = mp.upper_bound(55); /// 55 number key is no existed in map of mp so cout << (*itt).first << " " << (*itt).second << endl; /// get garbage value nothing more ///??? mp.find()
// The map::find() is a built-in function in C++ STL that returns an iterator or a constant iterator that refers to the position where the key is present in the map. If the key is not present in the map container, it returns an iterator or a constant iterator which refers to map.end() auto it = mp.find(10); if(it != mp.end()) { cout << "find " << endl; cout << (*it).first << " " << (*it).second << endl; } else cout << "not find" << endl;
///??? mp.count() and mp.erase() and print out using iterator instead of for each loop cout << "value of count " << mp.count(10) << endl; /// its like a boolean function ,, which tell us ,, is it existed or not existed,, if existed than return 1 else 0 ;; mp.erase(10); ///if we want to erase a (key and value) than we use ==>>mp.eraase(key or index) /// if no such of key is existed than it is not erase cout << "value of count " << mp.count(10) << endl; map<int , int>:: iterator iit; for(iit = mp.begin() ; iit != mp.end() ; iit++) cout << iit->first << " " << iit->second << endl; ///??? cout << "map of mpp print out " << endl; for(auto it : mpp) cout << it.first << " " << it.second << endl; ///??? /// application of swap function in between map of mpp and sayem /// after using swap function mpp is equal to sayem and sayem is equal to mpp its just a swap of two integer value map<int , int> sayem; sayem[1] = 11; sayem[2] = 22; sayem[3] = 33; sayem.swap(mpp); /// sayem.swap(mpp) is equal to mpp.swap(sayem) ;; in there no difference cout << "print out sayem" << endl; for(auto u : sayem) cout << u.first << " " << u.second << endl; cout << "print out mpp" << endl; for(auto u : mpp) cout << u.first << " " << u.second << endl; return 0;
OUTPUT :::::::::: 1 value of count 0 20 200 30 300 40 400 50 500 map of mpp print out 10 100 20 200 30 300 40 400 50 500 print out sayem 10 100 20 200 30 300 40 400 50 500 print out mpp 1 11 2 22 3 33
*******************************MULTI MAP ************************************** malti map is map which is capable to take same key in maltiple time ... in a sorted way (according to only key and valu has not any effect on it) and we cannot use mp.at() or [] operrator for assignment and there is adifference in lower_bound ==>> corresponding key of(minimum value is print out)
/* In the name of Allah, most gracious and most merciful */
include<bits/stdc++.h>
using namespace std;
define SR() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
define endl '\n'
define ff first
define ss second
define pb push_back
define pf push_front
define all(s) s.begin(),s.end()
const double pi = acos(-1); typedef long long ll; typedef unsigned long long ull;
int main()
{ SR(); multimap<int , int> mp , mpp ,cpp , sayem; mp.insert({1 , 10}); mp.insert({1 , 10}); mp.insert({2 , 20}); mp.insert({3 , 30}); mp.insert({4 , 40}); mp.insert({5 , 50}); mp.insert({1 , 5}); mp.insert({2 , 20}); mp.insert({3 , 30}); mp.insert({4 , 40}); mp.insert({5 , 50}); mp.insert({1 , 10}); mp.insert({1 , 10}); if(mp.empty()) cout << "EMPTY" << endl; else cout << "NOT EMPTY" << endl; cout << "SIZE " << mp.size() << endl; cout << "MAX SIZE " << mp.max_size() << endl; multimap<int , int>:: iterator it; for(it = mp.begin() ; it != mp.end() ; it++) /// mp.end() return next value last value or (last + 1) value cout << (*it).first << " " << (*it).second << endl; /// multiple key are present and sorted with according to key but multiple same key ,, sorted with ///??? cout << "ERASE KEY OF 1 FROM MALTI MAP OF mpp" << endl; mpp = mp; cpp = mp; mpp.erase(1); ///??? all key of declear (like 1) are erase mpp.erase(2); mpp.erase(3); for(auto u : mpp) cout << u.first << " " << u.second << endl; multimap<int , int>:: iterator iit; ///??? ins tead of s line ===>>> auto iit; those are same iit = cpp.begin(); // cpp.erase(iit); /// just first key and value are erase not all same key this is the difference in (((erase by key and iterator))) advance(iit , 0); ///??? we use advance function because of this function is not (((cpp.erase(iit , 1);))) workable //// advance(iit , 0); its mean iterator of first key and value cpp.erase(iit);///??? in there 3 means ///with out first and last value ,, if we want to erase some one than we use ((advance(iterator , index — 1) and erase (iterator))) both of them are done a single work cout << "CPP" << endl; for(auto u : cpp) cout << u.first << " " << u.second << endl; ///*** count(); function return how many time akey is appear in maltimap /// for a map value if count can be 0 or 1... because of map never assign same key multiple time just one time cout << "COUNT FUNCTION" << endl; cout << mp.count(1) << endl; ///*** find(); function ;; as map ,, same to same auto ittt = mp.find(1); if(ittt != mp.end()) cout << "FIND" << endl; else cout << "NOT FIND" << endl; ittt = mp.find(1000); if(ittt != mp.end()) cout << "FIND" << endl; else cout << "NOT FIND" << endl; ///??? mp.lower_bound(key) ===>>> if multiple key are stay than just smallest value of key is selected auto pp = mp.lower_bound(2); /// https://www.geeksforgeeks.org/multimap-lower_bound-function-in-c-stl/ cout << (*pp).first << " " << (*pp).second << endl; pp = mp.upper_bound(2); cout << (*pp).first << " " << (*pp).second << endl; pp = mp.lower_bound(5); cout << (*pp).first << " " << (*pp).second << endl; pp = mp.upper_bound(5); cout << (*pp).first << " " << (*pp).second << endl; /// return garbage value ===>>> if upper_bound(key or index) ,, index is max value than garbage value is printed
///??? swap function fr two multi_map sayem.insert({11 , 1000}); sayem.insert({11 , 1000}); sayem.insert({22 , 2000}); sayem.insert({33 , 3000}); sayem.insert({44 , 4000}); sayem.swap(mp); cout << "AFTER SWAPPING" << endl; cout << "MAP OF MP" << endl; for(auto u : mp) cout << u.first << " " << u.second << endl; cout << "MAP OF SAYEM" << endl; for(auto u : sayem) cout << u.first << " " << u.second << endl; return 0;
OUTPUT :::
NOT EMPTY SIZE 13 MAX SIZE 461168601842738790 1 10 1 10 1 5 1 10 1 10 2 20 2 20 3 30 3 30 4 40 4 40 5 50 5 50 ERASE KEY OF 1 FROM MALTI MAP OF mpp 4 40 4 40 5 50 5 50 CPP 1 10 1 5 1 10 1 10 2 20 2 20 3 30 3 30 4 40 4 40 5 50 5 50 COUNT FUNCTION 5 FIND NOT FIND 2 20 3 30 5 50 13 0 AFTER SWAPPING MAP OF MP 11 1000 11 1000 22 2000 33 3000 44 4000 MAP OF SAYEM 1 10 1 10 1 5 1 10 1 10 2 20 2 20 3 30 3 30 4 40 4 40 5 50 5 50
Recommend
-
82
One more step Please complete the security check to access codepen.io What can I do to prevent thi...
-
73
In the previous post ( https://statcompute.wordpress.com/2018/09/03/playing-map-and-reduce-in-r-by-group-calculation...
-
36
The Java Map interface, java.util.Map , represents a mapping between a key and a value. More specifically, a Java Map can store pairs of keys and values. Each key is linked to a specif...
-
36
map是Go语言中基础的数据结构,在日常的使用中经常被用到。但是它底层是如何实现的呢? map的整体结构图 Golang中map的底层实现是一个散列表,因此实现map的过程实际上就是实现散表的过程。在这个散列表中,主要出现的结构体有两个,一个叫hmap(a h
-
8
Finding all values for a key in multimap using equals_range – Example – thispointer.comMultimap store elements in key value pair. It can also have duplicate keys. There can be many scenarios when we want to find all the values associat...
-
2
Elden Ring Map: Where to find all of the map fragments By Bryn Gelbart published about 2 hours ago Piece together the Elden Ring map
-
10
SERIESHidden StructureA New Map of All the Particles and ForcesWe’ve created a new way to explore the fundamental constituents o...
-
7
Check if all values in a Map are Equal in C++ This tutorial will discuss how to check if all values in a map are equal in C++. To check if all the values in a map are equal or not, we can first fetch the value o...
-
4
Inside STL: The map, set, multimap, and multiset Raymond Che...
-
3
Inside STL: The unordered_map, unordered_set, unordered_multimap, and unordered_multiset
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK