Amazon Interview Question

Medium difficulty programming task on the phone