| 9 | |
| 10 | using namespace std; |
| 11 | signed main(){ |
| 12 | map<int, string> mp; |
| 13 | mp={{1,"a"},{2,"b"},{6,"c"},{3,"g"}}; |
| 14 | mp[8]="jh"; |
| 15 | // for(auto it:mp) |
| 16 | // cout<<it.first<<" "<<it.second<<endl; |
| 17 | // mp.erase(8);//O(log (n)) |
| 18 | auto it=mp.find(6); |
| 19 | if(it==mp.end()) |
| 20 | cout<<"no value"<<endl; |
| 21 | else |
| 22 | cout<<(*it).first<<" "<<(*it).second<<endl; |
| 23 | return 0; |
| 24 | } |
| 25 | //if key and value ae string then compl. is ==O(s.size()*log(n)) |