LeetCode No.54 | StriveZs的博客

LeetCode No.54

LeetCode第五十四题

自己代码的开源仓库:click here 欢迎Star和Folk :)

题目描述

给你一个 m 行 n 列的矩阵 matrix ,请按照 顺时针螺旋顺序 ,返回矩阵中的所有元素。

1
示例 1

figure.1

1
2
3
输入:matrix = [[1,2,3],[4,5,6],[7,8,9]]
输出:[1,2,3,6,9,8,7,4,5]
示例 2

figure.2

1
2
3
4
5
6
7
8
9
10
输入:matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
输出:[1,2,3,4,8,12,11,10,9,5,6,7]
 

提示:

m == matrix.length
n == matrix[i].length
1 <= m, n <= 10
-100 <= matrix[i][j] <= 100

代码

StriveZs wechat
Hobby lead  creation, technology change world.