Unique Paths in a Grid
Given a grid of size m x n, filled with 1's representing open paths and 0's representing obstacles, determine the number of unique paths from the top-left corner to the bottom-right corner of the grid. You are only allowed to move down or right at any point in time.
[ [ 1, 1 ], [ 0, 1 ] ]
Explanation. There is only one unique path avoiding the obstacle.
[ [ 1, 1, 1 ], [ 1, 0, 1 ], [ 1, 1, 1 ] ]
Explanation. There are two paths: Right, Right, Down, Down, Left and Down, Down, Right, Right.
[ [ 1, 1 ], [ 1, 1 ] ]
Explanation. There are two paths: Right, Down and Down, Right.
Follow-up: Could you solve the problem in O(m * n) time complexity using a dynamic programming approach?
1. Grid will be at least 1x1 and at most 100x100 in size.\n2. The start (top-left) and end (bottom-right) will always be open (1).
- Views
- 3