Unique Paths — 2-D DP
Count the routes a robot can take across a grid from top-left to bottom-right, moving only right or down.
2-D DP · Easy
The problem
A warehouse robot stands in the top-left cell of a grid with m rows and n columns and wants to reach the bottom-right cell. Each move takes it one cell right or one cell down. Count the different routes.
The story
A warehouse robot starts in the top-left cell of a grid with m rows and n columns, each from 1 to 18, and needs to reach the bottom-right cell. Every move takes it one cell right or one cell down. Count the different routes it could take; a 1 by 1 grid has exactly one, the empty route.
What to return
- Return the number of distinct routes from the top-left cell to the bottom-right cell.
- m is the number of rows and n the number of columns. A 1 x 1 grid has exactly one (empty) route.
- Large hidden tests (the biggest grids) run under a step budget of executed lines.
Constraints
- 1 <= m <= 18
- 1 <= n <= 18
- Your code may run at most 2,396 counted steps on the largest case.
Example
- Input
m = 4, n = 6- Output
56