Diagonal Traversal

unable to solve this probem

Hello @rabimajumder08,

You need to print matrix in a diagonal pattern like this, i.e, first upward diagonally, then downward diagonally, then upward and it goes on…

diagonal

The basic idea to solve this problem:
From the above diagram, it can be seen that starting position is (0,0). Start from the index (0,0), print it, and move to the next diagonal and also change your direction of printing. Initially, your direction is set upwards. This cycle continues until the last element is reached i.e index (m,n).

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.

sir i am unable to solve this,pls give me the solution

Hello @rabimajumder08,

You can refer to this article:

is there any lucid explanation available ??

@rabimajumder08,
There is no such logical explanation for this.
You just need to know pattern printing and be good at loops.