Amazon Interview Question

medium difficulty of leetcode problems