Spiral Matrix

Given an m x n matrix, return all elements of the matrix in spiral order.

Constraints

  • m == matrix.length
  • n == matrix[i].length
  • 1 <= m, n <= 10
  • -100 <= matrix[i][j] <= 100
Saving… · 2 lines
class Solution:
def spiralOrder(self, matrix: List[List[int]]) -> List[int]:
Console

Click Run to execute sample tests.