Mistake Clinic
Use the smallest reproducer that distinguishes the intended contract from the mistake. Save an actual attempt and repair; there is no required error quota.
Module-Specific Mistake Radar
| Symptom | Minimal probe | Likely cause and repair |
|---|---|---|
| Longest path repeats a vertex | Two paths with same endpoint but different visited sets | Missing history; augment state or use DAG assumptions |
| A zero answer is recomputed | Empty or impossible counting state | Truthiness used as cache membership; separate unseen from zero |
| A second query repeats the first answer | Digit bounds 25 then 9, target 3 | Cache survives changed fixed input; reset or key it |
| LIS accepts equal values | [2,2] | Upper-bound search implements nondecreasing semantics |
| LIS tails fail index order | [3,5,6,2,4] | Tails mistaken for witness; retain input predecessors |
| Empty string distance is zero | '' -> 'abc' | Missing boundary costs |
| Knapsack reports two copies | One (2,3) item, W=4 | Ascending update violates previous-item layer |
| Knapsack value right, witness wrong | Same one-item case with descending values | Mutable capacity parent points at a newer version |
| Grid invents a zero-reward route | All-negative 2-by-2 grid | Unreachable predecessors initialized to zero |
| Matrix tree has wrong cost | [5,2,4,3] | Split dimension factor or interval convention is wrong |
| Tree DP works on invalid graph | Triangle plus isolated vertex | Edge count used without connectedness/acyclicity checks |
| Tour omits closure | Two cities with no return edge | Open-path answer substituted for tour |
| Digit zero counted many times | Bound 100, sum 0 | Multiple representations or incorrect terminal semantics |
| Weighted schedule uses greedy | Two short jobs profit 3 each, one spanning profit 7 | Cardinality proof applied to weighted objective |
| DP time called table size | Matrix-chain split loop | Candidate work per state omitted |
Practice Mistake Checks
For P1–P5, inspect state sufficiency, dependency counts, cache lifetime and historical versions. For P6–P10, check strictness, alignment, capacity semantics, counted objects and impossible states. For P11–P20, check boundaries, structural preconditions, tour closure, digit padding and objective changes.
Classify each failure as state, decomposition, boundary, order, witness, cost or contract. Repair the explanation and code together. Recheck a fresh instance without the worked example. Persistent errors should send you to the matching concept and competency, not to a larger unrelated problem set.