Arrays-spiral print anticlockwise

I’m getting runtime error in my code though, given test case in passing. Please check whats wrong.

hey @sounakume you had many mistake in your code so i have updated it and commented the parts so that you can understand.(https://ide.codingblocks.com/s/174132)

I have added 2 questions in comments. Can u please check and reply?

hey @sounakume i didn’t saw any comments please save your code with comments and send me the link.


Here is the new link.

hey @sounakume
for your first doubt we are printing whole element of last row(not one element before) and currently your last element for last row will be in the (m-1)th column( 0 based indexing).

why we started from m-1 not m in the last for loop-
before this loop we have printed last column(m-1 was our last column since array is 0 indexed) now we are printing first row in the last for loop but we have already printed last element of first row(when we are printing last column) so we will start printing first row from m-2 but since m is already decremented start printing from m-1.

Yes i got it. I missed the decrementing of n for the 1st doubt. Thanks