IBM Interview Question

hackerrank coding assessment (leetcode style)