Question Bank

DP on Grids Quiz

Difficulty: Medium

Path counts, minimum path sum, and obstacle handling on rectangular grids. Code stems are Python.

Question Bank
/

DP on Grids Quiz

DP on Grids Quiz

Path counts, minimum path sum, and obstacle handling on rectangular grids. Code stems are Python.

Question Bank
Medium
Python
5 questions
grid-dp
dynamic-programming
algorithms
quiz

660 views

14

Implement unique_paths(m, n): count paths from the top-left to bottom-right of an m x n grid moving only right or down.

Examples

Example 1:

Input: m = 3, n = 7
Output: 28
Explanation: dp[r][c] = dp[r - 1][c] + dp[r][c - 1] with the first row and column all 1. Closed form C(m + n - 2, m - 1) = C(8, 2) = 28.