Amazon Interview Question

LeetCode Medium and sometimes hard question