Unique Paths
Medium Dynamic Programming
A grid has m rows and n columns. You start in its top-left cell and want to reach its bottom-right cell.
Each move goes one cell to the right or one cell down, never left or up, and never off the grid.
Return the number of different paths from the start to the end.
Example 1
Input: m = 3, n = 4
Output: 10
Each path makes 2 moves down and 3 moves right in some order, such as right, right, down, right, down. There are 10 different orders.
Example 2
Input: m = 5, n = 5
Output: 70
Example 3
Input: m = 1, n = 9
Output: 1
Constraints
1 ≤ m, n ≤ 100- The answer is at most 2³¹ − 1 = 2,147,483,647, so it fits a 32-bit int
Solve it here
Write it in Python, Java or C++, run it on your own cases, and submit against hidden tests.
Practice this in an AI round
30 minutes on this problem with an AI agent beside your code, then a report on your solution and how you used the agent.
See the AI roundWatch the explanation
More Dynamic Programming
- Maximum SubarrayAI round · Medium
- Best Time to Buy and Sell StockAI round · Easy
- Climbing StairsAI round · Easy
- Longest Increasing SubsequenceAI round · Medium
- Coin ChangeAI round · Medium