how to find 2d vector length cpp 1

how to find 2d vector length cpp

myVector[
  Vector[0, 4, 2, 5],
  Vector[1, 4, 2]
];

/*When you call for myVector[1].size() it would return 3 and [0] would return 4.

For the amount of rows (int vectors) in the 2d vector, you can just use myVector.size()

You can run this to see it in actions*/

Here is what the above code is Doing:
1. Create a vector of vectors of ints
2. Add a vector of ints to the vector of vectors
3. Add another vector of ints to the vector of vectors
4. Print the size of the vector of vectors
5. Print the size of the first vector of ints
6. Print the size of the second vector of ints

Similar Posts