A robot starts in the top-left cell of an m x n grid. At every move it may step only one cell to the right or one cell down, and it is trying to reach the bottom-right cell.
Return how many distinct paths the robot can take to travel from the top-left corner to the bottom-right corner.
Example 1
Input: m = 3, n = 7
Output: 28
There are 28 unique right/down routes across a 3 by 7 grid.
Example 2
Input: m = 3, n = 2
Output: 3
From the top-left the robot can reach the bottom-right corner in exactly three ways.
Constraints
1 <= m, n <= 100See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.
FDE Coach is a cohort-based program in frontend, backend, AWS, and AI where you build real products and get referred to 200+ hiring partners. The free live workshop is the fastest way to see how we teach.
750+ engineers trained · frontend, backend, AWS & AI