Back to DSA sheet

Spiral Matrix

MediumMatrix
Open on LeetCodeAmazonAppleGoogleMicrosoft

Return all elements of an m x n matrix in spiral order, starting from the top-left and moving clockwise.

Constraints
  • 1 <= m, n <= 10
  • matrix is m x n
Sheets
Blind 75Grind 75NeetCode 150NeetCode 250Striver A2Z
spiral-matrix.cpp
Loading editor
Custom input (stdin)
Output

Run your code to see its output.