mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
25 lines
1.1 KiB
HTML
25 lines
1.1 KiB
HTML
<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 "off limits" 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>"off limits" and empty grid are represented by <code>1</code> and <code>0</code> respectively.</p>
|
|
|
|
|
|
|
|
<p>Return a valid path, consisting of row number and column number of grids in the path.</p>
|
|
|
|
|
|
|
|
<p><strong>Example 1:</strong></p>
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
<strong>Input:
|
|
|
|
</strong>[
|
|
|
|
[<strong>0</strong>,<strong>0</strong>,<strong>0</strong>],
|
|
|
|
[0,1,<strong>0</strong>],
|
|
|
|
[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, c <= 100</code></li>
|
|
|
|
</ul>
|
|
|