Amazon Interview Question

Amazon question from their web