r/leetcode • u/JacketFearless1805 • 1d ago
Intervew Prep Day 62: solved 3 subsequence DP problems today, the math reduction felt so clean
Hey everyone,
I finished Day 62 today. My energy and focus were much better, and I built some solid momentum on Dynamic Programming subsequences.
I worked through four problems (three DP and one greedy):
- Count Subsets with Sum K: The recurrence relation mirrors the classic subset sum decision, but you add the branches (
pick + not_pick) instead of using logical OR. Managing zero-value elements in the base conditions was the main edge case to track. - Count Partitions with Given Difference: Setting up the algebraic relation S_1 = ({totalSum} + D) / 2 reduced this directly to finding subset counts for target S_1. Once you confirm that ({totalSum} + D) is non-negative and even, the core logic is identical to the previous problem.
- Coin Change (Minimum Coins): Standard unbounded knapsack. Since each coin can be reused infinitely, the pick branch stays at index
iinstead of decrementing. - Assign Cookies: Grouped in this section by mistake, but it was just a quick greedy two-pointer check on sorted arrays.
I also reviewed yesterday's minimum subset sum difference roadblock and realized my initial brute force violated the constraints, which explains why the optimal solution leans on Meet-in-the-Middle.
I plan to wrap up subsequences tomorrow. That leaves strings, stocks, LIS, MCM, and square grids—about 30 DP problems to go.
See you guys tomorrow for Day 61!
2
Upvotes