[PYTHON3] BFS + Pruning
Minimum cost problem can be reduced to BFS problem. We need to add the time constraints. So we pick the minimum cost node from the heap and when adding adjacenc
Minimum cost problem can be reduced to BFS problem. We need to add the time constraints. So we pick the minimum cost node from the heap and when adding adjacenct nodes of the picked node, we select them only if time can be reduced. We do not need to check cost since earliest visit to a node will have the minimum cost.\n```\nfrom collections import defaultdict\nfrom heapq import heappush, heappop\nclass Solution:\n    def minCost(self, maxTime: int, edges: List[List[int]], passingFees: List[int]) -> int:\n        n = len(passingFees)\n        adjacency = defaultdict(list)\n        min_times = {}\n        for src,dst,time in edges:\n            adjacency[src].append([dst,time])\n            adjacency[dst].append([src,time])\n        \n        heap = []\n        heappush(heap, (passingFees[0],0,0))\n        min_times[0] = 0\n        while heap:\n            cost,time,node = heappop(heap)\n            if node==n-1:\n                return cost\n            for dst,distance in adjacency[node]:\n                if time+distance<=maxTime and min_times.get(dst,float(\'inf\'))>time+distance:\n                    min_times[dst] = time+distance\n                    heappush(heap, ( cost+passingFees[dst], time+distance,dst))\n        return -1\n```
[]