IBM Interview Question

coding question similar to leetcode.