Arrays-Spiral Print Anticlockwise (TLE Error)

Two test cases give TLE. What can be the possible way to reduce time complexity. Here is my code https://ide.codingblocks.com/s/110366

Hi!
Please check the comments in the following code:

Also please note that the matrix may NOT always be a square matrix. It can be like 2,8 or 2,3 as well.

Thanks!