Not getting how to return output


Not getting “Fill in len1 as row, len2 as columns”.

Could you give an example what do I need to fill in len1 and len2 for 3?


you can’t use Vectors as Arrays , in your case I presume you know the logic with normal 2D array but are confused how to do the same by defining a 2D vector. here is the solution

vector < vector< int> > V;

Here V is a vector whose elements are vectors itself thus making a 2-D vector .

you can’t accesss vector elements like V[0][0] until they are already initialised with some value;
do the following

V.resize(R ,vector< int>( C ))

here resize is used to first create R rows and each row itself is a vector of C columns initialised with 0;

now you can use simple array operation ie V[0][1] etc etc to access any element

and in the end just use

return V;