Rat in a maze : Pattern is being printed in reverse order

The pattern that should be printed first is being printed last and vice versa, Why?

Ideally,
1 1 1 1
0001
0001
0001
should be printed first as per dry run, why is being printed last

hello @anshufirefox

image

first u r looking for down path (i+1,j) and then right path (i,j+1)
thats why u r getting this ->

in last

Oh, the coordinates work just like matrix coordinates right,
first row and then column?

I did the opposite here i guess

image

the cell numbering is like this.
(i,j) -> i is row no ,j is col no

Thank you so much :slight_smile:

Please help me close this thread by sending the rating link. (Unable to mark doubts resolved, the button doesn’t work in my profile. Have reported it to the support team)

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.