Unique Paths II

Problem A robot starts at the top-left of an m x n grid and moves only right or down toward the bottom-right corner. Some cells are obstacles (1) and cannot be entered. Return the number of unique obstacle-avoiding paths to the bottom-right.

Input / Output

  • Input: int grid obstacleGrid (0 = free, 1 = obstacle).
  • Output: the number of obstacle-avoiding paths.

Constraints

  • 1 <= m, n <= 100; the answer fits in a 32-bit int per the classic constraints.
  • The robot may only move right or down.

Example

  • [[0,0,0],[0,1,0],[0,0,0]] → 2.
asked …
LeaderboardSalaryAccount
Unique Paths II · 2dbi