Pregunta de entrevista de Amazon

graph based question and prirority queue