Dijkstra + DFS + DP (Does it get any better than this)
\nclass Solution {\n    int MOD = (int) (Math.pow(10, 9) + 7);\n    public int countRestrictedPaths(int n, int[][] edges) {\n        Map<Integer, List<int[]>> g
```\nclass Solution {\n    int MOD = (int) (Math.pow(10, 9) + 7);\n    public int countRestrictedPaths(int n, int[][] edges) {\n        Map<Integer, List<int[]>> graph = new HashMap<>();\n        for (int[] edge : edges) {\n            int from = edge[0];\n            int to = edge[1];\n            int dist = edge[2];\n\n            graph.putIfAbsent(from, new ArrayList<>());\n            graph.get(from).add(new int[]{to, dist});\n\n            graph.putIfAbsent(to, new ArrayList<>());\n            graph.get(to).add(new int[]{from, dist});\n        }\n\n        int[] distances = new int[n + 1];\n\n        Arrays.fill(distances, Integer.MAX_VALUE);\n        distances[n] = 0;\n\n        boolean[] visited = new boolean[n + 1];\n        PriorityQueue<int[]> pq = new PriorityQueue<>(Comparator.comparingInt(a -> a[1]));\n        pq.offer(new int[]{n, 0});\n\n        while (!pq.isEmpty()) {\n            int[] shortestDistanceNode = pq.poll();\n            int curr = shortestDistanceNode[0];\n            int dist = shortestDistanceNode[1];\n            visited[curr] = true;\n\n            if (distances[curr] < dist) {\n                //if we have already found a better distance, no need to add it again\n                continue;\n            }\n\n            for (int[] edge : graph.get(curr)) {\n                int next = edge[0];\n                int weight = edge[1];\n                if (!visited[next]) {\n                    int newDistance = distances[curr] + weight;\n\n                    // edge relaxation\n                    if (newDistance < distances[next]) {\n                        distances[next] = newDistance;\n                        pq.offer(new int[]{next, newDistance});\n                    }\n                }\n            }\n\n        }\n\n//        System.out.println(Arrays.toString(distances));\n\n        Map<Integer, Long> dp = new HashMap<>();\n        long count = dfs(graph, n, 1, distances, dp);\n        \n        return (int) (count % MOD);\n    }\n\n    private long dfs(Map<Integer, List<int[]>> graph, int n, int currentVertex, int[] distances, Map<Integer, Long> dp) {\n        if (currentVertex == n) return 1;\n\n        if (dp.containsKey(currentVertex)) return dp.get(currentVertex);\n\n        long count = 0;\n\n        for (int[] edge : graph.get(currentVertex)) {\n            int next = edge[0];\n            if (distances[currentVertex] > distances[next]) {\n                count += (dfs(graph, n, next, distances, dp) % MOD);\n            }\n        }\n        dp.put(currentVertex, count);\n        return count;\n    }\n}\n```
[]