Back to problems Solve on LeetCode → See #64 Min Path Sum → See #70 Climbing Stairs →

Unique Paths

LeetCode 62 • Medium • Dynamic Programming

m×n grid, start (0,0), end (m-1,n-1). Move only right or down. dp[i][j]=dp[i-1][j]+dp[i][j-1]. m=3, n=7 → 28.

TimeO(m×n)fill table
SpaceO(m×n)DP table
Current: Result:
Base (1)
Computed
Current
dp[i][j]
Ready
Press Play. dp[i][j] = paths to (i,j). dp[i][j] = dp[i-1][j] + dp[i][j-1]. First row/col = 1.