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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to find an element in an unordered_map

A

unordered_map<int,int> mp;
mp.find(key) != mp.end()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to iterate over characters in a string

A

for (char c : theString) { }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to initialize a vector of int and size n to x

A

vector<int> v(n, x);</int>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

iterator over items in vector automatically w/o index

A

vector<int> nums;
for(int i : nums ) { }</int>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to use sort in c++

A

include <algorithms></algorithms>

(void)sort(vec.begin(),vec.end());

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly