Dijkstra’s Algorithm || Striver code correction || Java
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(N*Log(N))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n)+O(n)=O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Pair{\n    long dis;\n    long node;\n    public Pair(long dis,long node){\n        this.dis=dis;\n        this.node=node;\n    }\n}\nclass Solution {\n    public int countPaths(int n, int[][] roads) {\n        ArrayList<ArrayList<Pair>> adj = new ArrayList<>();\n        for(int i=0;i<n;i++){\n            adj.add(new ArrayList<>());\n        }\n        for(int i=0;i<roads.length;i++){\n            adj.get(roads[i][0]).add(new Pair(roads[i][2],roads[i][1]));\n            adj.get(roads[i][1]).add(new Pair(roads[i][2],roads[i][0]));\n        }\n        PriorityQueue<Pair> pq = new PriorityQueue<>((x,y)->Long.compare(x.dis, y.dis));\n        long dis[]=new long[n];\n        long ways[]=new long[n];\n        for(int i=0;i<n;i++){\n            dis[i]=Long.MAX_VALUE;\n            ways[i]=0;\n        }\n        pq.add(new Pair(0,0));\n        dis[0]=0;\n        ways[0]=1;\n        int mod = (int) (1e9 + 7);\n        while(!pq.isEmpty()){\n            long currDis=pq.peek().dis;\n            int node=(int)(pq.peek().node);\n            pq.remove();\n            for(Pair it: adj.get(node)){\n                int adjNode = (int)it.node;\n                long edgeWeight = it.dis;\n                if(currDis+edgeWeight<dis[adjNode]){\n                    dis[adjNode]=currDis+edgeWeight;\n                    ways[adjNode]=ways[node];\n                    pq.add(new Pair(currDis+edgeWeight,adjNode));\n                }else if(currDis+edgeWeight==dis[adjNode]){\n                    ways[adjNode]= (ways[adjNode]+ways[node])%mod;\n                }\n            }\n        }\n        return (int)(ways[n-1]%mod);\n    }\n}\n```
['Java']