Yahoo interview question

Puzzles, algorithms