Unique Paths
Implement uniquePaths
Given the dimensions of a grid, starting at the top-left corner and only ever able to move one step right or one step down, count how many distinct paths reach the bottom-right corner.
Every cell's answer depends only on the two cells that could lead into it: the one directly above (reached by moving down into this cell) and the one directly to its left (reached by moving right into this cell). The number of paths through this cell is simply the sum of the paths that could arrive from each of those two directions, and the very first row and first column each have only one possible path — a straight line along the edge — since there's no cell above or to the left of them to arrive from. Filling in the grid this way, one row at a time from the top-left corner onward, builds up to the total path count at the bottom-right corner.
Example 1:
Input: m = 3, n = 4
Output: 10
Example 2:
Input: m = 4, n = 5
Output: 35
Example 3:
Input: m = 1, n = 6
Output: 1
+ 7 hidden test cases run on Submit.
Constraints:
- ●
1 ≤ m, n ≤ 100
m =
3
n =
4