Amazon Interview Question

To answer the technical question given.