Why testcase 0 is failing ?
Spiral print anticlockwise
In line 34 and 43, you need to put <= sign instead of only less than sign as the output should be printed even if endcol==startcol or endrow==startrow. Then it will be correct for all test cases.
Hope it Helps.