Count how many distinct ways there are to move from the top-left to the bottom-right of a grid using only right and down moves.
You are given two integers, and , describing an grid. A robot starts at the top-left cell and wants to reach the bottom-right cell.
At each step, the robot may move either one cell to the right or one cell down.
Return the number of distinct paths the robot can take to reach the destination.
Example 1
Input
m = 3, n = 7
Output
28
Explanation
There are 28 different ways to move from the top-left corner to the bottom-right corner using only right and down moves.
Example 2
Input
m = 3, n = 2
Output
3
Explanation
The three paths are: Right → Down → Down, Down → Right → Down, and Down → Down → Right.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.