Google interview question

String manipulation and array multiplication