Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
For example,
Given the following matrix:
[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]
You should return [1,2,3,6,9,8,7,4,5].
本文介绍了一个有趣的问题:如何按螺旋顺序遍历一个给定的 m x n 矩阵,并返回矩阵的所有元素。例如,对于一个 3x3 的矩阵 [[1,2,3],[4,5,6],[7,8,9]],螺旋遍历的结果应为 [1,2,3,6,9,8,7,4,5]。
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
For example,
Given the following matrix:
[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]
You should return [1,2,3,6,9,8,7,4,5].

被折叠的 条评论
为什么被折叠?