Pregunta de entrevista de Joco (NY)

weighted graph problem, give thoughts on solution