Given an m x n matrix, return all elements of the matrix in spiral order (clockwise, starting from the top-left corner).
Spiral order means: traverse the top row left to right, then the right column top to bottom, then the bottom row right to left, then the left column bottom to top, and repeat inward.
matrix = [[1,2,3],[4,5,6],[7,8,9]][1,2,3,6,9,8,7,4,5]matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]][1,2,3,4,8,12,11,10,9,5,6,7]matrix = [[1]][1]1 <= m, n <= 100-100 <= matrix[i][j] <= 100Run your code to see results
Use Cmd+Enter to run