Simple Solution
\nclass Solution {\n   public int countRestrictedPaths(int n, int[][] edges) {\n        List<List<int[]>> undirectedEdges = new ArrayList<>();\n        long[] c
```\nclass Solution {\n   public int countRestrictedPaths(int n, int[][] edges) {\n        List<List<int[]>> undirectedEdges = new ArrayList<>();\n        long[] cache = new long[n+1];\n        Arrays.fill(cache,-1);\n        cache[n]=1;\n        for(int i=0;i<=n;i++) \n            undirectedEdges.add(new ArrayList<>());\n        for(int[] edge: edges) {\n            undirectedEdges.get(edge[0]).add(new int[]{edge[0],edge[1],edge[2]});\n            undirectedEdges.get(edge[1]).add(new int[]{edge[1],edge[0],edge[2]});\n        }\n        Queue<int[]> queue = new PriorityQueue<>((e1,e2)->e1[1]-e2[1]);\n        int[] shortestDistance = new int[n+1];\n        Arrays.fill(shortestDistance,Integer.MAX_VALUE);\n        shortestDistance[n]=0;\n        queue.offer(new int[]{n,shortestDistance[n]}); \n        while(!queue.isEmpty()){  //dijkstra\'s algorithm\n            int curVertex = queue.poll()[0];\n            for(int[] edge: undirectedEdges.get(curVertex)){\n                int destination = edge[1];\n                int weight = edge[2];\n                if(shortestDistance[curVertex]+weight<shortestDistance[destination]){\n                    shortestDistance[destination]=shortestDistance[curVertex]+weight;\n                    queue.offer(new int[]{destination,shortestDistance[destination]});\n                }\n            }\n\n        }\n        return (int)dfs(undirectedEdges,shortestDistance,1,n,cache);\n    }\n    public long dfs(List<List<int[]>> undirectedEdges, int[] shortestDistance, int curVertex,int n,long[] cache){\n        long answer = 0;\n        if(curVertex==n) return 1;\n        if(cache[curVertex]!=-1) return cache[curVertex];\n        for(int[] edge: undirectedEdges.get(curVertex)){\n            if(shortestDistance[curVertex]>shortestDistance[edge[1]]) \n                answer+=dfs(undirectedEdges,shortestDistance,edge[1],n,cache);\n        }\n        return  cache[curVertex]=answer%1000_000_007;\n    }\n}\n```
['Dynamic Programming']