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

Constraints

Example

Input
m = 4, n = 6
Output
56

Solve it

More in 2-D DP

All algorithm problems