Pergunta de entrevista da empresa Jane Street

graph question with regular expressions