Pergunta de entrevista da empresa Google

Pretty straightforward question to do with finding substrings in strings