VISUALGO//PROBLEMS
unique paths · dp – multidimensionalmedium
LeetCode #62
dp
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
·
step
·
ELEMENTS
m
n
Python
def uniquePaths(m: int, n: int) -> int:
    dp = [[1] * n for _ in range(m)]  # one way along the top row and left column

    for r in range(1, m):
        for c in range(1, n):
            dp[r][c] = dp[r - 1][c] + dp[r][c - 1]  # arrive from above or from the left

    return dp[m - 1][n - 1]