IBM Interview Question

Solve a leetcode style question