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)/迷路的机器人 [robot-in-a-grid-lcci].html
2022-03-29 12:43:11 +08:00

23 lines
1.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>设想有个机器人坐在一个网格的左上角,网格 r 行 c 列。机器人只能向下或向右移动,但不能走到一些被禁止的网格(有障碍物)。设计一种算法,寻找机器人从左上角移动到右下角的路径。</p>
<p><img src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2018/10/22/robot_maze.png" style="height: 183px; width: 400px;"></p>
<p>网格中的障碍物和空位置分别用 <code>1</code><code>0</code> 来表示。</p>
<p>返回一条可行的路径,路径由经过的网格的行号和列号组成。左上角为 0 行 0 列。如果没有可行的路径,返回空数组。</p>
<p><strong>示例&nbsp;1:</strong></p>
<pre><strong>输入:
</strong>[
&nbsp; [<strong>0</strong>,<strong>0</strong>,<strong>0</strong>],
&nbsp; [0,1,<strong>0</strong>],
&nbsp; [0,0,<strong>0</strong>]
]
<strong>输出:</strong> [[0,0],[0,1],[0,2],[1,2],[2,2]]
<strong>解释:
</strong>输入中标粗的位置即为输出表示的路径,即
0行0列左上角 -&gt; 0行1列 -&gt; 0行2列 -&gt; 1行2列 -&gt; 2行2列右下角</pre>
<p><strong>说明:</strong><em>r</em>&nbsp;<em>c </em>的值均不超过 100。</p>