LIS, interval DP, bitmask DP, and tree DP patterns.
Advanced DP extends beyond linear and 2D tables into interval states, bitmask states, and tree structures. These appear in harder interview rounds and competitive programming.
LIS O(n log n) · Interval O(n³) · Bitmask O(2ⁿ × n)
Problem-dependent
Learn the core patterns in this topic. Each block explains when to use the pattern, the intuition behind it, and a compact code example.
Longest Increasing Subsequence: O(n²) DP or O(n log n) patience sort
dp[i][j] = answer for subarray i..j (matrix chain, burst balloons)
state = subset of elements; dp[mask] for TSP-style problems
dp[node] computed from dp[children]; rerooting technique
count numbers in range satisfying digit constraints
DP on column states for grid tiling problems