Google interview question

modified Dijkstra's algorithm