Siemens interview question

String manipulation problems from the internet