Java Dijkstras 100% Faster 100% Memory
```\n\tpublic int minCost(int maxTime, int[][] edges, int[] pf) {\n        int n= pf.length;\n        //adjacency matrix for time\n        int[][] adj= new int[
```\n\tpublic int minCost(int maxTime, int[][] edges, int[] pf) {\n        int n= pf.length;\n        //adjacency matrix for time\n        int[][] adj= new int[n][n];\n        for(int i=0; i<edges.length; i++){\n            int v1= edges[i][0], v2= edges[i][1], val= edges[i][2];\n            if(adj[v1][v2] == 0 || adj[v1][v2] > val){\n                adj[v1][v2]= val;\n                adj[v2][v1]= val;\n            }\n        }\n        // map is graph of connected nodes\n        Map<Integer,List<Integer>> map= new HashMap<>();\n        for(int i=0; i<n; i++){\n            map.put(i, new ArrayList<>());\n            for(int j=0; j<n; j++){\n                if(adj[i][j] == 0) continue;\n                map.get(i).add(j);\n            }\n        }\n        int[] minTime= new int[n];   \n        \n        //visited array, dont visit again if cost is greater than previous visited cost\n        Arrays.fill(minTime,Integer.MAX_VALUE);\n        \n        //Dijkstras w.r.t cost because we want min cost and if time becomes > maxTime we will stop\n        //exploring that path\n        Queue<int[]> minHeap= new PriorityQueue<>((a,b)->a[1]-b[1]);\n        minHeap.add(new int[]{0,pf[0],0});\n        while(!minHeap.isEmpty()){\n            int[] curr= minHeap.poll();\n            if(curr[2] > maxTime || curr[2] >= minTime[curr[0]]) continue;\n            if(curr[0] == n-1) return curr[1];\n            minTime[curr[0]]= curr[2];              //visit curr node with least possible time\n            for(int neigh : map.get(curr[0])){\n                int time= curr[2] + adj[curr[0]][neigh];\n                int cost= curr[1] + pf[neigh];\n                minHeap.add(new int[]{neigh,cost,time});\n            }\n        }\n        return -1;\n    }
[]