Mphasis interview question

medium level leetcode based on strings and arrays