Return all the values of the matrix in clockwise spiral order: along the top row left to right, down the right column, along the bottom row right to left, up the left column, then repeat on the inner part until every value is used.
Example 1
Input:
spiral_order([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
Output:
[1, 2, 3, 6, 9, 8, 7, 4, 5]
Example 2
Input:
spiral_order([[1, 2, 3, 4]])
Output:
[1, 2, 3, 4]
0 <= rows, cols, and rows * cols <= 250000No results yet
Run your code to check it against the examples, or submit to run every test.