Medium · Dynamic Programming

Unique Paths

Given the number of rows m and columns n of a grid, return how many distinct paths lead from the top-left cell to the bottom-right cell when every move goes one cell right or one cell down.

Examples

Example 1

{
  "m": 3,
  "n": 3
}

Output: 6 paths

Example 2

{
  "m": 3,
  "n": 4
}

Output: 10 paths

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Dynamic Programming problems