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 = 7
Output:28
Explanation:

There are 28 unique paths from top-left to bottom-right.

Input:m = 3, n = 2
Output:3
Explanation:

From the top-left to bottom-right, there are 3 ways: Right->Down->Down, Down->Down->Right, Down->Right->Down.

Input:m = 4, n = 3
Output:10
Explanation:

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

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!