[Python] Dijkstra Algorithm
Main observation is that we might reach the same node again searching for path that is under our time limit. Hence we apply BFS on that node again (if already a
Main observation is that we might reach the same node again searching for path that is under our time limit. Hence we apply BFS on that node again (if already applied) instead of dropping.\n```\nfrom collections import defaultdict\nfrom heapq import heappop,heappush\nclass Solution:\n    mn = float(\'inf\')\n    def minCost(self, mxt: int, edges: List[List[int]], fees: List[int]) -> int:\n        n = len(fees)\n        adj = defaultdict(list)\n        tms = defaultdict(lambda : float(\'inf\'))   ### need this dictionary to  account the reaching time at ith node. \n        for x,y,t in edges:\n            adj[x].append([y,t])\n            adj[y].append([x,t])\n        qu = []\n        heappush(qu,(fees[0],0,0))\n        while qu:\n            fee,tm,nd = heappop(qu)\n            if tm > mxt :\n                continue\n            if nd == n-1 :\n                return fee\n            if tm < tms[nd]:            ### simply if we come again at the same node and in lesser time we allow bfs over that node. \n                for dest,time in adj[nd]:\n                    heappush(qu,(fee+fees[dest],tm+time,dest))\n            tms[nd] = min(tms[nd],tm)  ## store the  min reachable  time at the  node\n        return -1\n\t\t
[]