![]() |
VOOZH | about |
Given a matrix of size n*m, and a point P(c, r). Print the matrix in a spiral form(clockwise) starting from the point P.
Examples :
Input : mat[][] = {{1 2 3},
{4 5 6},
{7 8 9}}
Point P = (0, 2)
Output : 3 6 5 2 9 8 7 4 1
The starting point is top left which
is 3.
This problem is mainly an extension of print a matrix in spiral form.
Implementation:
3 6 5 2 9 8 7 4 1
Time Complexity: O(max(low_row,low_column) x max(high_row , high_column))
Auxiliary Space: O(1)