Neeva Interview Question

a Leetcode easy to medium problem