Skip to content
intermediate

One-Dimensional Dynamic Programming

Solve problems with one-dimensional DP states, recurrences, base cases, and memory compression.

Problems

Problems in One-Dimensional Dynamic Programming

Practice problems that share this primary solution pattern and compare the clues that reveal it.

Minimalist dark-themed workspace with laptop and wireless keyboard.
advanced
12 min read

Longest Valid Parentheses

Counting matching pairs is not enough. The pairs must form one contiguous, well-formed region, and valid regions can nest, touch, or be separated by an…

View solution
Sunlit forest scene with a tree trunk and fallen leaves in autumn ambiance.
beginner
9 min read

Climbing Stairs

The reliable way to solve Climbing Stairs is to stop guessing “Fibonacci” and ask one structural question: what could the final move have been?

View solution
Open laptop with a colorful display reflecting on its keyboard, set against a dark background.
intermediate
11 min read

Decode Ways

The recurrence resembles Fibonacci, but zeros can remove transitions entirely. Derive the valid-token transitions first; the dynamic program then follows…

View solution
Explore the serene and vibrant beauty of a sprawling oak tree in a lush green forest, perfect for nature lovers.
intermediate
10 min read

Maximum Subarray

Resetting a running sum to zero looks like the obvious solution—until the array contains only negative numbers. Then the algorithm can quietly return an…

View solution