The problem
Twelve visually identical balls; one is a different weight, but you do not know whether heavier or lighter. Using a balance scale three times, identify the odd ball and whether it is heavy or light.
Start with the information argument
Before searching for a procedure, check whether one can exist. This is the part interviewers actually want.
Each weighing has three outcomes: left heavier, right heavier, balanced. Three weighings give 3^3 = 27 distinguishable results.
The question has 12 balls times 2 possibilities (heavy or light) = 24 answers.
24 is at most 27, so it is not ruled out - and the margin is tight, which tells you the solution cannot waste any information. That immediately rules out a first weighing of 6 vs 6, which can never balance and so yields only 2 outcomes instead of 3.
The solution
Weighing 1: balls 1-4 against 5-8.
If balanced, the odd ball is among 9-12 and you have two weighings for 8 possibilities (4 balls times 2) - which fits within 9. Weigh 9, 10, 11 against 1, 2, 3 (known good). If balanced, ball 12 is odd; one more weighing against a good ball gives its direction. If not, you know the direction and have three candidates: weigh 9 against 10 to finish.
If 1-4 is heavier, then one of 1-4 is heavy or one of 5-8 is light - 8 possibilities, two weighings left. Weigh 1, 2, 5 against 3, 4, 6.
- Balanced: the odd one is 7 or 8, and it is light. Weigh 7 against 8.
- Left heavy: either 1 or 2 is heavy, or 6 is light. Weigh 1 against 2.
- Right heavy: either 3 or 4 is heavy, or 5 is light. Weigh 3 against 4.
Symmetric if 5-8 is heavier.
The generalisation
With n weighings you can handle (3^n - 3)/2 balls: 4 balls with 2 weighings, 13 with 3, 40 with 4.
Note it is 13, not 12 - the classic puzzle is one short of the true maximum. If you have one known-good reference ball available, you can do 13.
What to say in the interview
Lead with the counting. "Three weighings give 27 outcomes and I need to distinguish 24, so it should be possible but with no slack - which means every weighing must be near-balanced three ways." That sentence is worth more than reciting the sequence.
More in brainteasers.