All problems
Unique Paths
Problem
Count the number of paths from the top-left to the bottom-right corner of an m by n grid when each move goes one cell right or one cell down.
Use dynamic programming where the first row and column are all 1 and every other cell is the sum of the cell above and the cell to the left. Assume m >= 1 and n >= 1.
Hint
Each cell is reachable only from the cell above and the cell to the left.
Test cases
case 1
in: [3,7]
expected: 28
case 2
in: [3,3]
expected: 6
case 3
in: [1,1]
expected: 1
case 4
in: [1,5]
expected: 1
case 5
in: [5,5]
expected: 70
Starter codePython
def unique_paths(m, n):
# Your code here
pass5 test cases · run your code against them in the editor