This program answers several independent “what’s the max of these values” queries in a row. Run the sample by
hand first: query 1’s values are 10 20 5 (max 20, correct), but query 2’s values are 1 2 3 – their actual max
is 3, yet the buggy program reports 20 again.
There’s no compile error here, and nothing undefined – this is the class of bug the lesson closes on: state that
silently outlives the call that set it. static gives a local variable a lifetime spanning the entire program
instead of just one call, which is exactly what you want for, say, a counter that persists across calls on
purpose – and exactly wrong here, where each call is supposed to start fresh. Find where best is declared, and
fix its lifetime, not the comparison logic (which is already correct).