1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (English)/迷路的机器人(English) [robot-in-a-grid-lcci].html

25 lines
1.0 KiB
HTML
Raw Normal View History

2022-03-29 12:43:11 +08:00
<p>Imagine a robot sitting on the upper left corner of grid with r rows and c columns. The robot can only move in two directions, right and down, but certain cells are &quot;off limits&quot; such that the robot cannot step on them. Design an algorithm to find a path for the robot from the top left to the bottom right.</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>&quot;off limits&quot; and empty grid are represented by&nbsp;<code>1</code> and&nbsp;<code>0</code>&nbsp;respectively.</p>
<p>Return a valid path, consisting of row number and column number of grids in the path.</p>
<p><strong>Example&nbsp;1:</strong></p>
<pre>
<strong>Input:
</strong>[
&nbsp; [<strong>0</strong>,<strong>0</strong>,<strong>0</strong>],
&nbsp; [0,1,<strong>0</strong>],
&nbsp; [0,0,<strong>0</strong>]
]
<strong>Output:</strong> [[0,0],[0,1],[0,2],[1,2],[2,2]]</pre>
<p><strong>Note: </strong></p>
<ul>
<li><code>r,&nbsp;c &lt;= 100</code></li>
</ul>