All problemsBack
Unique Paths
mediumThere 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.
Test Cases
Copy an input into themain harness and Run to verifyInput
m = 3, n = 7Expected Output
28Input
m = 3, n = 2Expected Output
3Explanation: Down-Down-Right, Down-Right-Down, and Right-Down-Down.
Constraints
- 1 <= m, n <= 100
Hints
Hint 1 — click to reveal
The number of ways to reach a cell is the sum of the ways to reach the cell above and the cell to its left.
Hint 2 — click to reveal
The first row and first column each have exactly one path.
Java Compiler
Powered by OneCompiler. Starter code loads automatically — edit and hit Run.