Pergunta de entrevista da empresa Joco (NY)

weighted graph problem, give thoughts on solution