LeetCode 62 Unique Paths - Solution

The core idea

Each cell can be reached from the cell above or the cell to the left.

dp[i][j] = number of paths to reach cell (i, j).

Recurrence: dp[i][j] = dp[i-1][j] + dp[i][j-1].

Base: first row and first column have only 1 path each (can only go straight right or straight down).

Answer: dp[m-1][n-1].