Package g0001_0100.s0063_unique_paths_ii
Class Solution
java.lang.Object
g0001_0100.s0063_unique_paths_ii.Solution
63 - Unique Paths II.<p>Medium</p>
<p>A robot is located at the top-left corner of a <code>m x n</code> grid (marked ‘Start’ in the diagram below).</p>
<p>The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked ‘Finish’ in the diagram below).</p>
<p>Now consider if some obstacles are added to the grids. How many unique paths would there be?</p>
<p>An obstacle and space is marked as <code>1</code> and <code>0</code> respectively in the grid.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/11/04/robot1.jpg" alt="" /></p>
<p><strong>Input:</strong> obstacleGrid = [[0,0,0],[0,1,0],[0,0,0]]</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> There is one obstacle in the middle of the 3x3 grid above. There are two ways to reach the bottom-right corner: 1. Right -> Right -> Down -> Down 2. Down -> Down -> Right -> Right</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/11/04/robot2.jpg" alt="" /></p>
<p><strong>Input:</strong> obstacleGrid = [[0,1],[0,0]]</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>m == obstacleGrid.length</code></li>
<li><code>n == obstacleGrid[i].length</code></li>
<li><code>1 <= m, n <= 100</code></li>
<li><code>obstacleGrid[i][j]</code> is <code>0</code> or <code>1</code>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
uniquePathsWithObstacles
public int uniquePathsWithObstacles(int[][] obstacleGrid)
-