Two Sum
Recognize the pattern
Brute force idea
The naive version of Two Sum sounds like this: Check every pair with nested loops. That direct path helps you understand the question, but it tends to treat every possibility as brand new instead of learning from earlier steps.
Better approach
A calmer way to see Two Sum is this: Use a hash map: for each number, check if (target - number) exists in the map. The goal is not to be clever for its own sake, but to remember the one relationship that keeps the solution grounded as you move forward.
Key invariant
The truth you want to protect throughout Two Sum is this: The map stores each number's value → index, so complement lookup stays immediate. If that remains true after every update, the rest of the reasoning has a stable place to stand.
Watch out for
The trap in Two Sum usually looks like this: Using the same element twice — check the map before adding the current number. When the code becomes mechanical before the idea is clear, small edge cases start breaking the whole story.