
Regular Expression Matching
A greedy scan breaks at * because the pattern can take two legal futures: skip the quantified element, or consume one matching character and keep the same…
View solutionModel DP problems that naturally require two coordinates or progress dimensions.
Problems
Practice problems that share this primary solution pattern and compare the clues that reveal it.

A greedy scan breaks at * because the pattern can take two legal futures: skip the quantified element, or consume one matching character and keep the same…
View solution
The table is easy to memorize and easy to misuse. The durable idea is simpler: track how far you have consumed each string, then let the final operation…
View solution
When both source strings can provide the next target character, a greedy pointer has to guess. Dynamic programming keeps both possibilities alive until the…
View solution
The right Minimum Path Sum solution is a two-dimensional dynamic program. For every coordinate, store the minimum sum needed to reach it from the top-left.…
View solution
The difficult part of the Scramble String solution is not recognizing that characters are rearranged. It is preserving the recursive boundaries that made…
View solution
The counting recurrence is only half the problem. To generate every tree, you must materialize every left/right subtree combination.
View solution
The reliable way to solve Unique Paths is to count paths to each cell, not to enumerate complete routes. Every cell has at most two meaningful…
View solution
The recurrence is familiar. The interview usually turns on the cells you forgot: a blocked start, a blocked destination, or an obstacle that permanently…
View solution
The reliable way to solve wildcard matching is to model it as reachability over two consumed prefixes—not as an improvised backtracking fight with *.
View solution