Pergunta de entrevista da empresa Intuit

It was a kinda easy graph problem.