Amazon Interview Question

almost average difficult, no too difficult one