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)/螺旋遍历二维数组 [shun-shi-zhen-da-yin-ju-zhen-lcof].html

33 lines
1.1 KiB
HTML
Raw Normal View History

2023-12-09 18:53:53 +08:00
<p>给定一个二维数组 <code>array</code>,请返回「<strong>螺旋遍历</strong>」该数组的结果。</p>
<p><strong>螺旋遍历</strong>:从左上角开始,按照 <strong>向右</strong><strong>向下</strong><strong>向左</strong><strong>向上</strong> 的顺序 <strong>依次</strong> 提取元素,然后再进入内部一层重复相同的步骤,直到提取完所有元素。</p>
<p>&nbsp;</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 &nbsp;= [[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>&nbsp;</p>
<p><strong>限制:</strong></p>
<ul>
<li><code>0 &lt;= array.length &lt;= 100</code></li>
<li><code>0 &lt;= array[i].length &lt;= 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>&nbsp;</p>