Pregunta de entrevista de Google

Pretty straightforward question to do with finding substrings in strings