Amazon interview question

Amazon question from their web