Unique Grid Descent Paths
easy
Dynamic ProgrammingMathCombinatoricsDp 2d
Asked atAmazonGoogleUberBloomberg
Problem Description
You are given an `rows × cols` grid. Starting from the **top-left cell** (row 0, column 0), you want to reach the **bottom-right cell** (row `rows-1`, column `cols-1`). At each step you may move **only right** or **only down**.
Return the total number of distinct paths from the top-left to the bottom-right.
**Example 1:**
```
Input: rows = 3, cols = 4
Output: 10
```
**Example 2:**
```
Input: rows = 2, cols = 2
Output: 2
Explanation: Right→Down, Down→Right
```
Constraints
- 1 <= rows, cols <= 18
Follow-up
What if some cells are blocked and cannot be traversed? Modify the DP to handle an obstacle grid.
Hints
Try the problem first. If you get stuck, you can reveal hints one at a time.
Solution
Leaderboard
No entries yet for python.
Be the first — submit an accepted solution.