Google interview question

String manipulation, algorithms, a bit of combinatorics