Amazon Interview Question

The coding interview problem was a leetcode hard.