My Java Solution using Djikstras algorithm
\nclass Solution {\n    public int minCost(int maxTime, int[][] edges, int[] passingFees) {\n        int length = passingFees.length;\n        List<int[]>[] gra
```\nclass Solution {\n    public int minCost(int maxTime, int[][] edges, int[] passingFees) {\n        int length = passingFees.length;\n        List<int[]>[] graph = buildGraph(edges, length);\n        int [] minimumTime = new int [length];\n        Arrays.fill(minimumTime, Integer.MAX_VALUE);\n        PriorityQueue<int []> pq = new PriorityQueue<>((a, b) -> Integer.compare(a[1], b[1]));\n        pq.add(new int [] {0, passingFees[0], 0});\n        // source, passingfee for source, totaltime\n        int time = 0;\n        int score = 0;\n        while (!pq.isEmpty()) {\n            int [] current = pq.poll();\n            if (current[2] >= minimumTime[current[0]])\n                continue;\n            minimumTime[current[0]] = current[2];\n            if (current[0] == length - 1)\n                return current[1];\n            for (int [] nextChild : graph[current[0]]) {\n                time = current[2] + nextChild[1];\n                score = current[1] + passingFees[nextChild[0]];\n                if (time > maxTime)\n                    continue;\n                if (time > minimumTime[nextChild[0]])\n                    continue;\n                pq.add(new int [] {nextChild[0], score, time});\n            }\n        }\n        return -1;\n    }\n    \n    public List<int[]>[] buildGraph(int [][] edges, int length) {\n        List<int[]> [] graph = new ArrayList[length];\n        for (int i=0; i<length; i++) {\n            graph[i] = new ArrayList<>();\n        }\n        for (int [] edge : edges) {\n            graph[edge[0]].add(new int [] {edge[1], edge[2]});\n            graph[edge[1]].add(new int [] {edge[0], edge[2]});\n        }\n        return graph;\n    }\n}\n```
['Graph', 'Java']