Amazon interview question

Some Puzzle