Simple | Dijkstra's Algorithm
Complexity
Time complexity: O(maxTime x N x log(maxTime x N))

Space complexity: O(maxTime x N)
Code
# Complexity
- Time complexity: O(maxTime x N x log(maxTime x N))
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(maxTime x N)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def minCost(self, maxTime: int, edges: List[List[int]], passingFees: List[int]) -> int:
        """
        Cost depends on node and time factor so 2D dist array
        ie dist[node][t] = cost (passingFeesSum)

        example: for node = 1
                 time = 0, 1, 2, 3 ... maxTime
        """
        
        n = len(passingFees)
        
        dist = [[float('inf') for i in range(maxTime + 1)] for i in range(n)]
        dist[0][0] = passingFees[0]

        vis = [[0 for i in range(maxTime + 1)] for i in range(n)]
        
        adj = []
        for i in range(n):
            adj.append([])

        for u, v, t in edges:
            adj[u].append((v,t))
            adj[v].append((u,t))
            
        
        h = []
        heappush(h, (dist[0][0], 0, 0)) # cost, node, time
        
        while h:
            cost, node, time = heappop(h)
            
            if vis[node][time] == 1:
                continue
            vis[node][time] = 1

            for v, t in adj[node]:
                if time + t > maxTime:
                    continue

                if dist[v][time + t] > (cost + passingFees[v]):
                    dist[v][time + t] = cost + passingFees[v]
                    heappush(h, (dist[v][time + t], v, time + t))
        
        
        ans = float("inf")
        for i in range(maxTime + 1):
            ans = min(ans, dist[n-1][i])

        # print(dist)
        
        return ans if ans != float('inf') else -1
        
        
```
['Graph', 'Shortest Path', 'Python3']