๐ WAYPOINT LESSON
Checkpoint: the missing number
โญ beginnerโณ 25 min read๐ Lesson 68 of 256
The sum trick: O(n), one pass, overflow-safe arithmetic.
The pattern: turn a search problem into arithmetic. The expected sum of 0..n is n(n+1)/2; whatever is missing from the actual sum IS the answer. Note the two traps the W commits: summing the wrong thing, and letting n*(n+1) overflow int before the long division.