IBM Interview Question

leetcode easy to medium problem solving.