2023-12-09 18:42:21 +08:00
|
|
|
|
<p>在 <code>rows x cols</code> 的网格上,你从单元格 <code>(rStart, cStart)</code> 面朝东面开始。网格的西北角位于第一行第一列,网格的东南角位于最后一行最后一列。</p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p>你需要以顺时针按螺旋状行走,访问此网格中的每个位置。每当移动到网格的边界之外时,需要继续在网格之外行走(但稍后可能会返回到网格边界)。</p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p>最终,我们到过网格的所有 <code>rows x cols</code> 个空间。</p>
|
2022-03-27 20:46:41 +08:00
|
|
|
|
|
|
|
|
|
<p>按照访问顺序返回表示网格位置的坐标列表。</p>
|
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p><strong class="example">示例 1:</strong></p>
|
|
|
|
|
<img alt="" src="https://s3-lc-upload.s3.amazonaws.com/uploads/2018/08/24/example_1.png" style="width: 174px; height: 99px;" />
|
|
|
|
|
<pre>
|
|
|
|
|
<strong>输入:</strong>rows = 1, cols = 4, rStart = 0, cStart = 0
|
2022-03-27 20:46:41 +08:00
|
|
|
|
<strong>输出:</strong>[[0,0],[0,1],[0,2],[0,3]]
|
|
|
|
|
</pre>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p><strong class="example">示例 2:</strong></p>
|
|
|
|
|
<img alt="" src="https://s3-lc-upload.s3.amazonaws.com/uploads/2018/08/24/example_2.png" style="width: 202px; height: 142px;" />
|
|
|
|
|
<pre>
|
|
|
|
|
<strong>输入:</strong>rows = 5, cols = 6, rStart = 1, cStart = 4
|
2022-03-27 20:46:41 +08:00
|
|
|
|
<strong>输出:</strong>[[1,4],[1,5],[2,5],[2,4],[2,3],[1,3],[0,3],[0,4],[0,5],[3,5],[3,4],[3,3],[3,2],[2,2],[1,2],[0,2],[4,5],[4,4],[4,3],[4,2],[4,1],[3,1],[2,1],[1,1],[0,1],[4,0],[3,0],[2,0],[1,0],[0,0]]
|
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
|
|
<p><strong>提示:</strong></p>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<ul>
|
|
|
|
|
<li><code>1 <= rows, cols <= 100</code></li>
|
|
|
|
|
<li><code>0 <= rStart < rows</code></li>
|
|
|
|
|
<li><code>0 <= cStart < cols</code></li>
|
|
|
|
|
</ul>
|