Google interview question

basic string manipulation and array