C++✅✅| Simplest approach (Dijkstra + DP)🚀🚀
\n\n# Code\n\nclass Solution {\npublic:\n    int countRestrictedPaths(int n, vector<vector<int>>& edges) {\n        vector<pair<int, int>> adj[n + 1];\n        
\n\n# Code\n```\nclass Solution {\npublic:\n    int countRestrictedPaths(int n, vector<vector<int>>& edges) {\n        vector<pair<int, int>> adj[n + 1];\n        for(auto it : edges){\n            adj[it[0]].push_back({it[1], it[2]});\n            adj[it[1]].push_back({it[0], it[2]});\n        }\n        vector<int> dis(n + 1, INT_MAX);\n        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;\n        pq.push({0, n});\n        dis[n] = 0;\n        while(!pq.empty()){\n            auto [wt, node] = pq.top();\n            pq.pop();\n            for(auto [v, edgeWeight] : adj[node]) {\n                if(dis[node] + edgeWeight < dis[v]) {\n                    dis[v] = dis[node] + edgeWeight;\n                    pq.push({dis[v], v});\n                }\n            }\n        }\n        vector<int> dp(n + 1, -1);\n        function<int(int)> dfs = [&](int node) -> int {\n            if(node == 1) return 1;\n            if(dp[node] != -1) return dp[node];\n            int ways = 0;\n            for(auto [v, wt] : adj[node]){\n                if(dis[node] < dis[v]){\n                    ways = (ways + dfs(v)) % 1000000007;\n                }\n            }\n            return dp[node] = ways;\n        };\n        return dfs(n);\n    }\n};\n```
['Dynamic Programming', 'Graph', 'Heap (Priority Queue)', 'Shortest Path', 'C++']