Google interview question

Simple code with strings