๐ WAYPOINT LESSON
Off-by-One and Boundary Tests
โญโญโญ advancedโณ 30 min read๐ Lesson 187 of 281
Difference arrays, half-open ranges, and reversed reads โ the bugs that pass every symmetric test you try by hand.
Design tests that kill the bug class
Off-by-one survives [l, r] = [1, n] tests because both directions are symmetric. Kill it with asymmetric ranges: [1,2] then [2,4] on n = 4. Half-open semantics: an interval [a, b) ending at t does not overlap [t, ...]. Reversed l/r reads pass palindromic data โ always include one lopsided op.
โก Now practice
Ready to CodeBug HuntPair sums at 4e9, subtree sizes on a 200000-node bamboo, and 200000 difference-array ops.
3 challenges ยท ยท ~110 min