Blind 75
59 / 75Free practice

Unique Paths

Medium · Dynamic programming

Jump to code

Count paths from the top-left to the bottom-right of an m×n grid, with m,n ≥ 1. Each move goes one cell right or down. There are no obstacles.

Examples

Example 1

m = 3
n = 7

Output: 28

Example 2

m = 3
n = 2

Output: 3

Constraints

  • 1 <= m, n <= 100
  • The result fits a signed 32-bit integer.
Need a hint?

A cell can be entered only from above or from the left.

Real dynamic programming interview questions

Questions on the same topic that candidates reported from real company interviews. Some company questions are locked and open with Premium or XP.

Browse all real coding interview questions

Accepted submissions mark this problem complete. Progress stays in this browser.

Run checks 5 examples. Submit checks all 8 cases. A free account runs this problem; no XP needed.
Language
Case 1
Input
[
  3,
  7
]
Expected
28
Case 2
Input
[
  3,
  2
]
Expected
3
Case 3
Input
[
  1,
  1
]
Expected
1
Case 4
Input
[
  1,
  5
]
Expected
1
Case 5
Input
[
  7,
  3
]
Expected
28

Drafts are saved per language in this browser when storage is available.