Java Solution PriorityQueue
Please upvote if you like the solution :)\n\n\nclass Solution {\n    List<int []> [] graph;\n    \n    public int minCost(int maxTime, int[][] edges, int[] pass
Please upvote if you like the solution :)\n\n```\nclass Solution {\n    List<int []> [] graph;\n    \n    public int minCost(int maxTime, int[][] edges, int[] passingFees) {\n        int n = passingFees.length;\n        graph = new List [n];\n        \n        int [] minTime = new int [n];\n        \n        Arrays.fill(minTime, Integer.MAX_VALUE);\n        \n        for (int i = 0; i < n; ++i){\n            graph[i] = new ArrayList<>();\n        }\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        \n        PriorityQueue<int []> queue = new PriorityQueue<>((a, b) -> a[1] - b[1]);\n        \n        queue.add(new int [] {0, passingFees[0], 0});\n        \n        // node, fee, time spent\n        int [] current;\n        int size;\n        \n        int time, score;\n        \n        while (!queue.isEmpty()){\n            current = queue.poll();\n            \n            if (current[2] >= minTime[current[0]])\n                continue;\n            \n            minTime[current[0]] = current[2];\n            \n            if (current[0] == n - 1)\n                return current[1];\n            \n            for (int [] next : graph[current[0]]){\n                time = current[2] + next[1];\n                score = current[1] + passingFees[next[0]];\n                \n                if (time > maxTime)\n                    continue;\n                else if (time > minTime[next[0]])\n                    continue;\n                \n                queue.add(new int [] { next[0], score, time });\n            }\n        }\n        \n        return -1;\n    }\n}\n```
[]