Google interview question

Leetcode medium. String and array manipulation.