1. XOR Is the Sum, AND Is the Carry Optimal
Intuition
Addition without carrying IS exclusive-or; the carries are exactly the positions where both bits were set, shifted one place left. Apply both repeatedly and the carry runs out. In Java the int wraps for free; in Python the unbounded integers need a 32-bit mask every round, or a negative operand makes the carry climb forever — that non-termination is the actual lesson of writing it there.
Algorithm
1. Sum without carry: a XOR b.
2. Carry: (a AND b) shifted left one.
3. Repeat with those two until the carry is zero.
4. In Python, mask to 32 bits each round and convert the result to its signed reading.
Time & Space
Time O(32). Space O(1).