Find row and col in a 2d matrix

int calculate( vector<vector> matrix )

matrix.size();// it returns no.of rows in the matrix.

How to find no.of columns in the matrix( If not square matrix )?

Hey @yogeshcsc20 for that you have to use for loop and iterate over matrix, then have to print matrix[i].size to get the number of columns on ith row of matrix :slight_smile:

If any STL is present to find the end element index of the matrix, then also we can find the row and col. Please provide if any.

Well I don’t know or I don’t think there’s any stl function for that moreover if you stl want to know about the stl function I would suggest you to go at https://www.cplusplus.com/ vector section :slight_smile:

Thanks it worked matrix.size()//gives rows and matrix[0].size()//gives columns

I told you that :slight_smile: