Amazon interview question

Puzzles