Leetcode, Python, Solutions, Problem Solving, Cruio.
if u==node2: return d if d>dist[u]: continue for v,w in self.adj_list[u]: if d+w<dist[v]: dist[v]=d+w heapq.heappush(pq,(dist[v],v)) return -1 # Your Graph object will be instantiated and called as such: # obj = Graph(n, edges) # obj.addEdge(edge) # param_2 = obj.shortestPath(node1,node2) Bhupesh