std used Flashcards
1
Q
What is unordered_map<type key,type value>
A
Unordered map is an associative container that contains key-value pairs with unique keys. Search, insertion, and removal of elements have average constant-time complexity.
2
Q
How to find an element in an unordered_map
A
unordered_map<int,int> mp;
mp.find(key) != mp.end()
3
Q
How to iterate over characters in a string
A
for (char c : theString) { }
4
Q
How to initialize a vector of int and size n to x
A
vector<int> v(n, x);</int>
5
Q
iterator over items in vector automatically w/o index
A
vector<int> nums;
for(int i : nums ) { }</int>
6
Q
How to use sort in c++
A
include <algorithms></algorithms>
(void)sort(vec.begin(),vec.end());
7
Q
A