Wrong answer in spiral

https://hack.codingblocks.com/contests/c/452/440/submissions
https://ide.codingblocks.com/#/s/14291

1 Like

Hy Amritanshu,
I just found that your code gives wrong answer for the case
2 3
1 2 3
4 5 6

You just need to update the conditional statement of erow and ecol to greater than equal to
The following snippet might help

if(erow>=srow){
       for(i=ecol;i>=scol;i--)
            cout<<a[erow][i]<<' ';
       erow--;
}