C++ Graph :Dijikstra + DP Based Well Commented Solution
IntuitionStep1: find dist of all nodes from n
Step2 : Using DP find all paths such that : distanceToLastNode(zi) > distanceToLastNode(zi+1).....Complexity
Time
# Intuition
Step1: find dist of all nodes from n 
Step2 : Using DP find all paths such that : distanceToLastNode(zi) > distanceToLastNode(zi+1).....


# Complexity
- Time complexity: $$O(n)$$ 
<!-- Add your time complexity here, e.g.  $$O(n)$$ -->
 
- Space complexity: $$O(n)$$ 
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
#define p pair<int,int>
#define mod 1000000007
class Solution {
public:

    int dp[20001];
    int recurs(unordered_map<int,vector<p>>&graph,vector<int>&dist, int n,int node){
        if(node == n)
            return 1;
        
        if(dp[node]!=-1)
            return dp[node];


        int ans = 0;
        for(auto x:graph[node]){
            int node_x = x.first;
            if(dist[node_x]<dist[node]){ //distanceToLastNode(zi) > distanceToLastNode(zi+1)
                ans+=recurs(graph,dist,n,node_x)%mod;
                ans%=mod;
            }
        }
        return dp[node]=ans;
    }

    int countRestrictedPaths(int n, vector<vector<int>>& edges) {

        memset(dp,-1,sizeof(dp));
        vector<int>dist(n+1,INT_MAX);
        unordered_map<int,vector<p>>graph;
        priority_queue<p,vector<p>,greater<p>>pq;

        int ans = 0;
        dist[n] = 0;
        pq.push({0,n});

        for(auto x:edges){ // graph construction
            graph[x[0]].push_back({x[1],x[2]});
            graph[x[1]].push_back({x[0],x[2]});
        }

        // STEP 1:
        // fetching shortest distance from n->to all other nodes
        while(pq.size()){
            int node = pq.top().second;
            int distance = pq.top().first;
            pq.pop();

            for(auto x:graph[node]){
                int node_x = x.first, dist_x = x.second;
                if(dist[node_x] > (distance+dist_x)){ // we have found some shorter path to reach here than prev.
                    dist[node_x] = (distance+dist_x);
                    pq.push({dist[node_x],node_x});
                }
            }
        }

        // STEP 2:
        ans = recurs(graph,dist,n,1);

        return ans;
    }
};
```
['C++']