Description
There is a robot on an m x n grid. The robot is initially located at the top-left corner. The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid. How many possible unique paths are there?
Examples
Input:
m = 3, n = 7Output:
28Explanation:
There are 28 unique paths from top-left to bottom-right.
Input:
m = 3, n = 2Output:
3Explanation:
From the top-left to bottom-right, there are 3 ways: Right->Down->Down, Down->Down->Right, Down->Right->Down.
Input:
m = 4, n = 3Output:
10Explanation:
To reach from top-left (0,0) to bottom-right (3,2), the robot must make exactly 3 moves right and 2 moves down, totaling 5 moves. The number of unique paths is the number of ways to choose 3 positions out of 5 for the right moves (or equivalently, 2 positions for the down moves), which is C(5,3) = C(5,2) = 10.
Constraints
- •
1 ≤ m, n ≤ 100