Unique Paths
Problem A robot starts in the top-left cell of an m x n grid and may only move right or down. Count the distinct paths it can take to reach the bottom-right cell.
Input / Output
- Input: two integers m (rows) and n (columns).
- Output: the number of unique paths from cell (0,0) to cell (m-1, n-1).
Constraints
- 1 <= m, n <= 100.
- Only two moves are legal from any cell — one step right or one step down. No diagonals, no backtracking.
- The answer fits in a 32-bit signed integer at these limits, but it grows combinatorially, so overflow is worth revisiting if the bounds rise.
Example
- m=3, n=7 → 28.
- m=3, n=2 → 3: the paths are Right-Down-Down, Down-Right-Down, Down-Down-Right.
- m=1, n=1 → 1 (the empty path) — the base case that off-by-one implementations get wrong.
asked …