Blind 75
Unique Paths (medium)
Problem Statement
Given a 2-dimensional grid of size m x n
(where m
is the number of rows and n
is the number of columns), you need to find out the number of unique paths from the top-left corner to the bottom-right corner. The constraints are that you can only move either right or down at any point in time.
Examples
-
Example 1:
- Input: 3, 3
- Expected Output: 6
- Justification: The six possible paths are:
- Right, Right, Down, Down
- Right, Down, Right, Down
- Right, Down, Down, Right
- Down, Right, Right, Down
- Down, Right, Down, Right
- Down, Down, Right, Right
-
Example 2:
- Input: 3, 2
- Expected Output: 3
- Justification: The three possible paths are:
- Right, right, down
- Right, down, right
- Down, right, right
-
Example 3:
- Input: 2, 3
- Expected Output: 3
- Justification: The three possible paths are:
- Down, right, right
- Right, down, right
- Right, right, down
Constraints:
1 <= m, n <= 100
Try it yourself
Try solving this question here:
Python3
Python3