java dijkstra+dp beats 100% easy to understand
\nclass Solution {\n    public int countRestrictedPaths(int n, int[][] edges) {\n        List<int[]>[] graph=new List[n+1];\n        for(int i=0;i<graph.length;
```\nclass Solution {\n    public int countRestrictedPaths(int n, int[][] edges) {\n        List<int[]>[] graph=new List[n+1];\n        for(int i=0;i<graph.length;i++)graph[i]=new ArrayList<>();\n        for(int[] edge:edges)\n        {\n            graph[edge[0]].add(new int[]{edge[1],edge[2]});\n            graph[edge[1]].add(new int[]{edge[0],edge[2]});\n        }\n        PriorityQueue<int[]> queue=new PriorityQueue<>((a,b)->a[0]-b[0]);\n        queue.add(new int[]{0,n});\n        int[] dic=dijkstra(graph,queue,n);\n        Integer[] res=new Integer[n+1];\n        return dfs(dic,1,n,res,graph);\n    }\n    public int dfs(int[] dic,int start,int n,Integer[] res,List<int[]>[] graph)\n    {\n        if(start==n)return 1;\n        if(res[start]!=null)return res[start];\n        int ans=0;\n        for(int[] nei:graph[start])\n        {\n            if(dic[start]>dic[nei[0]])\n            {\n                ans=(ans+dfs(dic,nei[0],n,res,graph))%1000000007;\n            }\n        }\n        res[start]=ans;\n        return ans;\n        \n    }\n    public int[] dijkstra(List<int[]>[] graph,PriorityQueue<int[]> queue,int n)\n    {\n        int[] dic=new int[n+1];\n        Arrays.fill(dic,Integer.MAX_VALUE);\n        while(!queue.isEmpty())\n        {\n            int[] temp=queue.poll();\n            if(dic[temp[1]]==Integer.MAX_VALUE)\n            {\n                dic[temp[1]]=temp[0];\n                for(int[] nei:graph[temp[1]])\n                {\n                    queue.offer(new int[]{temp[0]+nei[1],nei[0]});\n                }\n            }\n        }\n        //System.out.println(dic[2]);\n        return dic;\n    }\n}\n```
[]