An invariant is a statement that stays true while an algorithm runs. Before coding, write down what must remain true after each loop iteration. For a two-pointer scan, that might be: every element left of the left pointer has already been ruled out. This small habit turns debugging into checking a clear claim rather than guessing at edge cases.

These are working notes, not the last word. The goal is to keep the learning loop visible: try a concept, explain it simply, then revisit it with a better question.