1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/螺旋矩阵 [spiral-matrix].html

29 lines
988 B
HTML
Raw Normal View History

2022-03-27 20:56:26 +08:00
<p>给你一个 <code>m</code><code>n</code> 列的矩阵 <code>matrix</code> ,请按照 <strong>顺时针螺旋顺序</strong> ,返回矩阵中的所有元素。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2020/11/13/spiral1.jpg" style="width: 242px; height: 242px;" />
<pre>
<strong>输入:</strong>matrix = [[1,2,3],[4,5,6],[7,8,9]]
<strong>输出:</strong>[1,2,3,6,9,8,7,4,5]
</pre>
<p><strong>示例 2</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2020/11/13/spiral.jpg" style="width: 322px; height: 242px;" />
<pre>
<strong>输入:</strong>matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
<strong>输出:</strong>[1,2,3,4,8,12,11,10,9,5,6,7]
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>m == matrix.length</code></li>
<li><code>n == matrix[i].length</code></li>
<li><code>1 <= m, n <= 10</code></li>
<li><code>-100 <= matrix[i][j] <= 100</code></li>
</ul>