
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 solutionSolve problems with one-dimensional DP states, recurrences, base cases, and memory compression.
Problems
Practice problems that share this primary solution pattern and compare the clues that reveal it.

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
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
The recurrence resembles Fibonacci, but zeros can remove transitions entirely. Derive the valid-token transitions first; the dynamic program then follows…
View solution
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
The shape is what you count; BST ordering is what makes each root split deterministic.
View solution