Simple Java Djikstra
\nclass Solution {\n    public int minCost(int maxTime, int[][] edges, int[] passingFees) {\n        int n = passingFees.length;\n        int destination = n-1;
```\nclass Solution {\n    public int minCost(int maxTime, int[][] edges, int[] passingFees) {\n        int n = passingFees.length;\n        int destination = n-1;\n        int source = 0;\n        Integer[] timeHold = new Integer[n];\n        Arrays.fill(timeHold, Integer.MAX_VALUE);\n\n        Map<Integer,List<int[]>> graph = new HashMap();\n        for(int[] edge : edges){\n            int src = edge[0];\n            int dst = edge[1];\n            int time = edge[2];\n            graph.putIfAbsent(src,new ArrayList());\n            graph.putIfAbsent(dst,new ArrayList());\n            graph.get(src).add(new int[]{dst,time});\n            graph.get(dst).add(new int[]{src,time});\n        }\n        \n        PriorityQueue<int[]> pq = new PriorityQueue<int[]>( (a, b) -> a[1] - b[1] ); //a[0] = city, a[1] = cost, a[2] = time\n        pq.offer(new int[]{source, passingFees[source], 0});\n        timeHold[0] = 0;\n        while(!pq.isEmpty()){\n            int[] node = pq.poll();\n            int src = node[0];\n            int fee = node[1];\n            int time = node[2];\n\n            if(src == destination) // check whether destination reached ?\n                return fee;\n            \n            for(int[] nei : graph.get(src)){\n                \n                int neiNode = nei[0];\n                int neiTime = nei[1];\n                                              \n                if(time + neiTime > maxTime) // we cannot exceed maxTime, return .. \n                    continue;\n                \n                if(time + neiTime < timeHold[neiNode]){\n                    timeHold[neiNode] = time + neiTime; //we found lesser time update time Array and add this node to pq..\n                    pq.add(new int[]{neiNode, fee + passingFees[neiNode], timeHold[neiNode]});\n                }\n            }\n        }\n        return -1;\n    }\n}\n```
['Java']