Pergunta de entrevista da empresa HackerRank

If was an easy question about graphs