IBM Interview Question

Leetcode style question from easy to mid range.