Unique Paths
Medium
Math
Dynamic Programming
Combinatorics
There is a robot on an `m x n` grid. The robot is initially located at the **top-left corner**. The robot tries to move to the **bottom-right corner**. The robot can only move either down or right at any point in time. Given the two integers `m` and `n`, return *the number of possible unique paths that the robot can take to reach the bottom-right corner*.
Example 1
Input: m = 3, n = 7
Output: 28
Example 2
Input: m = 3, n = 2
Output: 3

Constraints

  • 1 <= m, n <= 100
  • The answer is guaranteed to be less than or equal to 2 * 10⁹.
Time Complexity
O(m*n)
Space Complexity
O(n)
14
Case 1
Input: 3 7
Expected: 28
Case 2
Input: 3 2
Expected: 3
Case 3
Input: 1 1
Expected: 1