Spiral Matrix
Given a 2-d array matrix
, return elements in spiral order starting from matrix[0][0]
.
Constraints
n, m ≤ 250
wheren
andm
are the number of rows and columns inmatrix
https://binarysearch.com/problems/Spiral-Matrix
Examples
Example 1
Input
- matrix =
[[ 6, 9, 8],
[ 1, 8, 0],
[ 5, 1, 2],
[ 8, 0, 3],
[ 1, 6, 4],
[ 8, 8,10]]
Output
- answer =
[6, 9, 8, 0, 2, 3, 4, 10, 8, 8, 1, 8, 5, 1, 8, 1, 0, 6]
Leave a comment