Amazon Interview Question

A Leetcode Medium Problem - Can't be specific due to NDA