Small grid
Input
m = 3, n = 7
Output
28
There are C(3+7-2, 3-1) = C(8,2) = 28 distinct sequences of moves (down/right) to reach the end.
Full lesson preview
Compute the number of unique paths from top-left to bottom-right in an m x n grid moving only right or down.
Problem statement
Task
Examples
Input
m = 3, n = 7
Output
28
There are C(3+7-2, 3-1) = C(8,2) = 28 distinct sequences of moves (down/right) to reach the end.
Input format
Output format
Constraints
Samples
Input
m = 1, n = 5
Output
1
Only one way when there's only one row: move right each time.