← 返回 bytedance 的题目列表Robot Grid Paths
类型:online_judge
bytedance
A robot is located at the top-left corner of an MxN grid marked as grid[0][0]. The grid cells are either 0 or 1, where 0 indicates a passable cell and 1 indicates an impassable cell. The robot can only move either down or right, and it aims to reach the bottom-right corner of the grid. Write a function to calculate the number of unique paths from the top-left to the bottom-right corner.
Input
A two-dimensional array grid of size MxN, where grid[i][j]=0 or grid[i][j]=1. 1 ≤ M, N ≤ 100
Output
An integer representing the number of unique paths from top-left to bottom-right.
Example
Input:
`grid = [ [0, 0, 0], [0, 1, 0], [0, 0, 0] ]`
Output:
`2`
Notes
Paths cannot pass through obstacles (i.e., cells with 1).
Example
Input
[[0,0,0],[0,1,0],[0,0,0]]