๐ WAYPOINT LESSON
Checkpoint: two bugs, one method
โญโญ intermediateโณ 30 min read๐ Lesson 152 of 256
Full localization loop on secondMax โ tracking logic plus the distinctness report.
secondMax teaches the deepest lesson of the module: the original else
branch silently records the LAST smaller value, not the second LARGEST
โ a semantic error invisible to a single test. And the -1 report via
max == second breaks for negatives (try {-1, -2}: max stays 0!). The
repair needs a proper two-slot tracker and a boolean 'was there a
second?' โ exactly the kind of redesign the exam asks you to diagnose,
not just the one-token fixes.