Pregunta de entrevista de Google

The first question is string manipulation. The second is graph.