Google Interview Question

String manipulation, algorithms, a bit of combinatorics