Amazon Interview Question

To code a solution to leetcode style question