Skip to interview prep
Apexed

42. Unique Paths

MediumDynamic programming

A robot starts at the top-left of an m × n grid and can only move right or down. Return the number of distinct paths to the bottom-right corner.

Example 1

Input: m = 3, n = 7
Output: 28

Example 2

Input: m = 3, n = 2
Output: 3

Constraints

  • 1 ≤ m, n ≤ 100
  • The answer fits in a 32-bit integer for the tests

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 4 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Unique Paths — coding interview practice — Apexed