Spiral print anticlockwise

can you tell me where i am wrong?

Hello @nilotpal i have corrected your code and commented the mistake:

yeah! but the code is failing in one test case and passing in 3.

@nilotpal check now:

Yeah! its accepted now. but if we remove that part, wont we be printing same element twice in m*n matrices?

5 3
1 2 3
4 5 6
7 8 9
10 11 12
13 14 15

Try this input, you will see 8 is printing twice if we exclude that condition

yes right: but if you want to add that then you have to make the count like this:

okay! thanks. gotcha

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.