Google interview question

string manipulation based. based on given inputs