Spiral order
hardLists40 XP
Return the numbers of matrix (a list of equal-length rows) in spiral order: along the top row, down the right side, back along the bottom and up the left, then the same again further in.
Examples
- Input: matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]Output: [1, 2, 3, 6, 9, 8, 7, 4, 5]
- Input: matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]Output: [1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7]
Examples use JSON: true/false/null are True/False/None in Python.