Amazon interview question

The puzzle in third round