Count all paths from a to b
Description
See LeetCode 62
Dynamic Programming Solution
Let $dp[i][j]$ to be the total unique paths to $board[i][j]$, the state transision is easy to find:
|
|
$$ dp[i][j] = dp[i-1][j] + dp[i][j-1] $$
- Define a custom indexing function to take care of corner cases.
- The filling order is described as follow for $row=3, col=4$:
0 | 1 | 2 | 3 |
---|---|---|---|
4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 |
|
|