Java Dijkstra + DFS with memo
```\nclass Item {\n    int node;\n    int max;\n}\n\nclass Solution {\n    private long response = 0;\n    \n    public int countRestrictedPaths(int n, int[][] 
```\nclass Item {\n    int node;\n    int max;\n}\n\nclass Solution {\n    private long response = 0;\n    \n    public int countRestrictedPaths(int n, int[][] edges) {\n         int[] distance = new int[n + 1];\n        int[] visited = new int[n + 1];\n        \n        PriorityQueue<int[]> heap = new PriorityQueue<>(Comparator.comparing(a -> a[1]));\n        Map<Integer, List<int[]>> graph = new HashMap<>();\n        \n        Arrays.fill(distance, Integer.MAX_VALUE);\n        distance[n] = 0;\n        distance[0] = 0;\n        \n        for(int i = 0; i < edges.length; i++) {\n            List<int[]> neighbors = graph.getOrDefault(edges[i][0], new LinkedList<>());\n            neighbors.add(new int[]{edges[i][1], edges[i][2]});\n            graph.put(edges[i][0], neighbors);\n            \n            List<int[]> neighbors2 = graph.getOrDefault(edges[i][1], new LinkedList<>());\n            neighbors2.add(new int[]{edges[i][0], edges[i][2]});\n            graph.put(edges[i][1], neighbors2);\n            \n        }\n        \n        heap.offer(new int[]{n, 0});\n        \n        while(!heap.isEmpty()) {\n            int u = heap.peek()[0];\n            int distUFromRoot = heap.poll()[1];\n            if(visited[u] == 1) continue;\n            visited[u] = 1;\n            \n            if(graph.containsKey(u)) {\n                for(int[] neighbor : graph.get(u)) {\n                    int v = neighbor[0];\n                    int w = neighbor[1];\n                    if(visited[v] == 0) {\n                        int newDistanceVFromRoot = Math.min(distance[v], w + distUFromRoot);\n                        distance[v] = newDistanceVFromRoot;\n                        heap.offer(new int[]{v, newDistanceVFromRoot});\n                    }\n                }\n            }\n        }\n        \n      // print(distance);\n        \n        //response = 0;\n        int []vis = new int[n + 1];\n        long response = dfs(graph, 1, distance[1], vis, distance, n, new HashMap<>());\n        return (int)(response % 1000000007);\n    }\n    \n     private void print(int temp[]){\n        for(int i = 0; i < temp.length; i++){\n            System.out.print(temp[i] + " ");\n        }\n\t\tSystem.out.println();\n    }\n    \n    private long dfs(Map<Integer, List<int[]>> graph, int node, int maxDistance, int []visited, int dist[], int n, Map<Integer, Long> map) {\n        if(node == n) {\n            return 1;\n        }\n        \n        if(visited[node] == 1) {\n            return 0;\n        } \n        \n        if(map.get(node) != null) {\n            return map.get(node);\n        }\n         \n        visited[node] = 1;\n        long curr = 0;\n        for(int []edge : graph.get(node)) {\n            if(visited[edge[0]] == 1) {\n                continue;\n            }\n            \n            if(dist[edge[0]] < maxDistance) {\n                curr += (dfs(graph, edge[0], dist[edge[0]], visited, dist, n, map) % 1000000007);\n            }\n        }\n        \n        visited[node] = 0;\n        map.put(node, curr);\n        \n        return curr;\n       // visited.remove(node);\n    }\n}
['Depth-First Search', 'Memoization', 'Java']