Extreme Networks interview question

String traversal and the logic behind it