Python3 modified Dijkstra
A dictionary timeTable keep track the minimum time spent reaching each city.\nThe DIjkstra is based on totalFee. If one city has been already visited in the alg
A dictionary timeTable keep track the minimum time spent reaching each city.\nThe DIjkstra is based on totalFee. If one city has been already visited in the algorithm and the timespent is not shorter than the previous visit, the city is not considered anymore. \n\n```\nclass Solution:\n    def minCost(self, maxTime: int, edges: List[List[int]], passingFees: List[int]) -> int:\n        destination = len(passingFees) - 1\n        timeTable = {}\n        graph = {}\n        for e in edges:\n            u = e[0]\n            v = e[1]\n            d = e[2]\n            \n            if u not in graph:\n                graph[u] = [(v, d)]\n            else:\n                graph[u].append((v, d))\n                \n            if v not in graph:\n                graph[v] = [(u, d)]\n            else:\n                graph[v].append((u, d))\n                \n        # print(graph)\n        \n        queue = [(passingFees[0], 0, 0)] # [(totalfee, city, timespent)...]\n        \n        while(queue):\n            totalFee, city, timeSpent = heapq.heappop(queue)\n            if timeSpent > maxTime:\n                continue\n            elif city == destination:\n                return totalFee\n            elif city in timeTable and timeSpent >= timeTable[city]:\n                continue\n            else:\n                timeTable[city] = timeSpent\n                for nextCity in graph[city]:\n                    heapq.heappush(queue,(totalFee + passingFees[nextCity[0]], nextCity[0], timeSpent + nextCity[1]))\n            \n        return -1\n        \n```
[]