Amazon interview question

Remove the duplicate