vector
and vector< vector
both are 2D array.
But what is the differenc
vector
is a vector containing vectors. In this example, you have a vector with 26 vectors contained in it. The code v[1].push_back(x)
means that x
is pushed back to the first vector within the vectors.
vector
is an array of vectors. In other words, a one-dimensional array containing 26 vectors of integers. The code a[1].push_back(x);
has x
being pushed back to the first index of the array.