3Sum
Recognize the pattern
Brute force idea
The naive version of 3Sum sounds like this: Three nested loops checking every triplet. 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 3Sum is this: Sort, fix one element, two-pointer scan for the other two. 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 3Sum is this: Sort first, then for each element, use two pointers on the remaining array to find pairs summing to its negative. If that remains true after every update, the rest of the reasoning has a stable place to stand.
Watch out for
The trap in 3Sum usually looks like this: Duplicate triplets — skip elements equal to the previous one at each level. When the code becomes mechanical before the idea is clear, small edge cases start breaking the whole story.