Diagonal traversal

giving me run time error my program. could u help to find out…?

@amaaanahmedkhan987,
You haven’t initialised matrix vector to appropriate size.
Try this
vector<vector<int>> matrix(n, vector<int>(m));

https://ide.codingblocks.com/s/291471 still my code is not working pls modify my code

https://ide.codingblocks.com/s/291471 still my code is not working pls modify my code

@amaaanahmedkhan987,
Because on line 14, you are going out of bounds (may be row or col is greater than the dimension of matrix). You can dry run on sample test case.

pls modify my code for me i am not able to correct my mistake

@amaaanahmedkhan987,

Code
You can dry run now on this,

Input
3 3
1 2 3 4 5 6 7 8 9

i am not able to modify my code … could u modify my code

@amaaanahmedkhan987,
It is a very simple program, you should be able to do it itself, at least the dry run. Please share me an image of your dry run on paper and pen.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.