DP Questions I Saw Coming and Still Missed
Four DP problems I recognized in the interview and still got wrong. Coin change with the wrong order of loops, LIS in O(n^2), edit distance with a missing base case, and a 2D grid DP with overcounted moves.
By @hannahdelgado
November 30, 2025
·
Updated August 9, 2026
319 views
7
4.3 (12)
Coin change: number of ways to make amount using unlimited coins from coins. I wrote the right recurrence but with the loops nested in the wrong order, which overcounted ordered sequences.
How I should have framed it
The outer loop is coins (each coin considered once), the inner loop is amount (build up answers). Outer-amount, inner-coins counts permutations; outer-coins, inner-amount counts combinations.
3 more questions and all solutions are locked.
Purchase this item to access all questions, code snippets, and solutions.
