mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
33 lines
1.1 KiB
HTML
33 lines
1.1 KiB
HTML
<p>给定一个二维数组 <code>array</code>,请返回「<strong>螺旋遍历</strong>」该数组的结果。</p>
|
||
|
||
<p><strong>螺旋遍历</strong>:从左上角开始,按照 <strong>向右</strong>、<strong>向下</strong>、<strong>向左</strong>、<strong>向上</strong> 的顺序 <strong>依次</strong> 提取元素,然后再进入内部一层重复相同的步骤,直到提取完所有元素。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>array = [[1,2,3],[8,9,4],[7,6,5]]
|
||
<strong>输出:</strong>[1,2,3,4,5,6,7,8,9]
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>array = [[1,2,3,4],[12,13,14,5],[11,16,15,6],[10,9,8,7]]
|
||
<strong>输出:</strong>[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>限制:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>0 <= array.length <= 100</code></li>
|
||
<li><code>0 <= array[i].length <= 100</code></li>
|
||
</ul>
|
||
|
||
<p>注意:本题与主站 54 题相同:<a href="https://leetcode-cn.com/problems/spiral-matrix/">https://leetcode-cn.com/problems/spiral-matrix/</a></p>
|
||
|
||
<p> </p>
|