‹ DS&A interview · Socratic
DSA · Dynamic Programming · #182

Unique Paths

Module 47 · difficulty 3/5·30:00starts on first keystroke

A robot sits in the top-left cell of an `m x n` grid. It can only move **right** or **down** one cell at a time, and wants to reach the bottom-right cell. Implement `uniquePaths(m, n)` that returns the number of distinct paths the robot can take.

Examples
  • m = 3, n = 7 28
  • m = 3, n = 2 3Down+Down+Right, Down+Right+Down, Right+Down+Down.
  • m = 1, n = 1 1Already at the destination.
Constraints
  • · 1 <= m, n <= 100
  • · The answer is guaranteed to fit in a 32-bit signed integer.
Session phases
A · Clarify
B · Approach
C · Complexity
D · Edges
E · Code
F · Tradeoff
G · Score
Phase A — Clarify
Ask questions about input bounds, types, and edge constraints.
Ask the coach clarifying questions about the problem.
When you've covered this phase, advance to the next.