Spiral Matrix
MediumGiven an m x n matrix, print all of its elements in spiral order, starting at the top-left corner and moving clockwise.
Input format:
- First line: m n
- Next m lines: n integers each
Print the elements on one line, separated by spaces.
Constraints
1 <= m, n <= 1000 1 <= m * n <= 2 * 10^5 -10^9 <= matrix[i][j] <= 10^9