Sum of Two Integers
Signals to notice
Brute force first
Not applicable in the usual sense — the constraint IS the challenge. It is a fair place to begin because it matches the surface of the question, yet it does not capture the deeper structure that makes the problem simpler.
The key insight
XOR gives the sum without carries. AND shifted left gives the carries. Repeat until there are no carries. iterations max for 32-bit integers. Instead of recomputing the world every time, you preserve just enough context to let the next decision become obvious.
What must stay true
a XOR b adds bits without carrying. (a AND b) << 1 produces the carries. Adding these two results is the same problem — recurse until carry is 0. As long as that statement keeps holding, you can trust the steps built on top of it.
Easy way to go wrong
In languages without fixed-width integers (Python), this can loop infinitely with negative numbers. Use a 32-bit mask to simulate fixed-width arithmetic. Most mistakes here are not about syntax; they come from losing track of what your state, pointer, or structure is supposed to mean.