3

Please Please tell me what are time complexities of these DS operations in C++

 1 year ago
source link: https://codeforces.com/blog/entry/115878
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.
neoserver,ios ssh client

By coderbolt, history, 95 minutes ago,

1) unordered_map<int, int> map1;

  • i) cout << map1[20] << "\n"; ---> getting value using key, when key is integer
  • ii) map1.find(20) != map1.end() ---> finding value using key, when key is integer

2) ordered_map<int, int> map2;

  • i) cout << map2[20] << "\n"; ---> getting value using key, when key is integer
  • ii) map2.find(20) != map2.end() ---> finding value using key, when key is integer

3) unordered_map<string, int> map3;

  • i) cout << map3["banana"] << "\n"; ---> getting value using key, when key is string
  • ii) map3.find("apple") != map3.end() ---> finding value using key, when key is String

4) ordered_map<int, int> map4;

  • i) cout << map4["banana"] << "\n"; ---> getting value using key, when key is string
  • ii) map4.find("apple") != map4.end() ---> finding value using key, when key is string

5) vector vec5 = {"Apple", "Mango", "Banana", "peanuts", "Cherry"};

sort(vec5.begin(), vec5.end())  ---> sorting a vector of strings

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK