IBM interview question

Medium String Question - Available in LeetCode