Dynamic Programming•Pattern: Grid DP•Medium

Unique paths in a grid

Problem Intuition & Objective

Count all unique paths from top-left to bottom-right moving only right or down.

Time ComplexityO(m×n)
Optimal
Space ComplexityO(n) with 1D DP
Memory Bounds
Optimal Algorithmic Approach

2D DP or combinatorics formula.

Core Invariants & Edge Cases

  • dp[i][j] = dp[i-1][j] + dp[i][j-1]
  • First row and column all 1s
  • Math shortcut: C(m+n-2, m-1) — combinatorics
Previous Problem0/1 Knapsack problemNext Problem Word break — can string be segmented into dictionary words?

System Design & Architecture Roadmap

Coding interviews are only 50% of the bar. Master High-Level Design, distributed systems, and Object-Oriented LLD.