Java Variables Failed When Scope Hid State

The bug was not in the algorithm. It was a variable that looked harmless during code review.