Dynamic Programming21 sections · 916 units
Open in Course

Common Mistakes - Walkthrough

Debugging tips

Mistake 11: Wrong bit indexing. Decide: bit 0=leftmost0 = leftmost or rightmost column? Stay consistent. Mistake 22: Forgetting to process cells in order. Column by column, row by row.

Don't jump around. Mistake 33: Invalid initial/final states. Start with mask=0mask = 0 (nothing filled). End with mask=0mask = 0 (everything filled). Mistake 44: Off-by-one in grid dimensions. Carefully index rows and columns from 00 or 11. Off-by-one errors are especially common. Test on 2x2 and 2x3 grids where you can verify by hand.