Spiral Matrix

Try to solve the Spiral Matrix problem.


Given an m×nm\times n matrix, return an array containing the matrix elements in spiral order, starting from the top-left cell.


  • 11\leq matrix.length 10\leq 10
  • 11\leq matrix[i].length 10\leq 10
  • 100-100\leq matrix[i][j] 100\leq 100


Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy