STL Flashcards
1
Q
Size of vector
A
v.size()
2
Q
Is vector empty
A
v.empty()
3
Q
Vector of 10 vectors
A
vector< int > v[10];
4
Q
Vector of size 10
A
vector< int > v(10);
5
Q
Add new element to the vector
A
v.push_back(i);
6
Q
Clear vector
A
v.clear()
7
Q
Vector of 20 strings
A
vector< string > v(20, “Unknown”);
8
Q
N*M matrix filled with -1
A
vector< vector< int > > Matrix(N, vector< int >(M, -1));
9
Q
Pass vector to function
A
void function(vector< int > &v);
10
Q
Declare stack
A
stack< int > s;
11
Q
Push to stack
A
s.push(i)
12
Q
Pop from stack
A
s.pop()
13
Q
Top of the stack
A
s.top()
14
Q
Is stack empty
A
s.empty()
15
Q
Size of stack
A
s.size()
16
Q
Pair is defined in which header?
A