Amazon Interview Question

One easy or medium leetcode style question