noodleProblems/
Unique Paths
#69

Unique Paths

AlgorithmmediumMathDynamic ProgrammingCombinatorics

A robot sits in the top-left cell of an m x n grid. It can move only **right** or **down**, one cell at a time, and wants to reach the bottom-right cell.

Return the number of distinct paths the robot can take.

Example cases

  • 3x7 grid
    in m = 3, n = 7
    out 28
  • 3x2 grid
    in m = 3, n = 2
    out 3
    Down-down-right, down-right-down, right-down-down.
  • 1x1 grid
    in m = 1, n = 1
    out 1
    Already at the destination.

Constraints

  • 1 <= m, n <= 100
  • The answer fits in a 32-bit signed integer.
Saved
m =
3
n =
7