0
0
DSA Typescriptprogramming~5 mins

Unique Paths in Grid DP in DSA Typescript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the problem statement of the Unique Paths in Grid DP?
Find the number of different ways to move from the top-left corner to the bottom-right corner of a grid, moving only down or right.
Click to reveal answer
beginner
What does the DP state represent in Unique Paths problem?
DP state dp[i][j] represents the number of unique paths to reach cell (i, j) from the start (0, 0).
Click to reveal answer
intermediate
What is the recurrence relation used in Unique Paths DP?
dp[i][j] = dp[i-1][j] + dp[i][j-1], meaning paths to current cell = paths from above + paths from left.
Click to reveal answer
beginner
Why do we initialize the first row and first column with 1 in Unique Paths DP?
Because there is only one way to reach any cell in the first row (all moves right) or first column (all moves down).
Click to reveal answer
advanced
How does Unique Paths DP handle obstacles if added to the grid?
Cells with obstacles have dp[i][j] = 0, meaning no paths go through them; other cells sum paths from neighbors if not blocked.
Click to reveal answer
In Unique Paths DP, what does dp[0][0] represent?
ANumber of rows
BNo paths available
CStarting point with 1 path
DNumber of obstacles
Which moves are allowed in the Unique Paths grid problem?
ADown and Left
BUp and Left
CUp and Right
DDown and Right
What is the time complexity of the Unique Paths DP solution for an m x n grid?
AO(m + n)
BO(m * n)
CO(m^2 * n^2)
DO(1)
If dp[i][j] = 0 in Unique Paths with obstacles, what does it mean?
ACell is unreachable or blocked
BCell has multiple paths
CCell is the start
DCell is the destination
How do you compute dp[i][j] if there are no obstacles?
Adp[i][j] = dp[i-1][j] + dp[i][j-1]
Bdp[i][j] = dp[i-1][j] * dp[i][j-1]
Cdp[i][j] = max(dp[i-1][j], dp[i][j-1])
Ddp[i][j] = dp[i-1][j] - dp[i][j-1]
Explain how to use dynamic programming to find the number of unique paths in a grid.
Think about how paths build from top-left to bottom-right.
You got /4 concepts.
    Describe how obstacles affect the Unique Paths DP solution and how to handle them.
    Obstacles block paths, so no paths go through those cells.
    You got /3 concepts.