c++ dynamic programming(memoization+dfs) + dijktra's algorithm..
// c++ dynamic programming + dijktra\'s algorithm..\n// step1--> use dijktra\'s shortest path algorithm to obtain shortes distance of all node from "nth node ie
// c++ dynamic programming + dijktra\'s algorithm..\n// step1--> use dijktra\'s shortest path algorithm to obtain shortes distance of all node from "nth node ie last node"..\n// step 2---> run dfs from nth to 1st node with condition distanceToLastNode(zi) > distanceToLastNode(zi+1)...\n// step 3--->store dp[node number] as it indicate number of path from node "node number " to first ie 1th node ,utilise stored  result if                  same   node is  again came in path.\n\n// below is my code ..  do upvote if you like my approach..  :)\n\n\n    \n    int dis[20001];\n    \n    int dp[20001];\n    \n     int M=1e9+7;\n    \n    void dijkatras(int n,vector<pair<int,int>> adlist[])\n    {\n        vector<int> vis(n+1,-1);\n        \n        vis[n]=1;\n        dis[n]=0;\n        set<pair<int,int>> pq;\n        pq.insert(make_pair(0,n));\n        \n        while(pq.empty()==false)\n        {\n            auto it=*(pq.begin());\n            pq.erase(pq.begin());\n            \n            for(auto i:adlist[it.second])\n            {\n                if(dis[i.first]>dis[it.second]+i.second)\n                {\n                    auto ptr=pq.find(make_pair(dis[i.first],i.first));\n                    \n                    if(ptr!=pq.end()) pq.erase(ptr);\n                    \n                    dis[i.first]=dis[it.second]+i.second;\n                    pq.insert(make_pair(dis[i.first],i.first));\n                }\n            }\n        }\n    }\n    \n    \n   \n    \n    long long int dfs(int n,vector<pair<int,int>> adlist[],int d)\n    {\n        \n        if(n==1) return 1;\n        \n         int ans=0;\n        \n        if(dp[n]!=-1) return dp[n];\n        \n        for(auto i:adlist[n])\n        {\n        if(d<dis[i.first]) ans =(ans%M+dfs(i.first,adlist,dis[i.first])%M)%M;//distanceToLastNode(zi) > distanceToLastNode(zi+1) condition \n        }\n        return  dp[n]= ans;\n        \n    }\n    \n    int countRestrictedPaths(int n, vector<vector<int>>& edges) {\n        \n      for(int i=1;i<=n;i++) dis[i]=INT_MAX;\n        \n        for(int i=1;i<=n;i++) dp[i]=-1;\n        \n        vector<pair<int,int>> adlist[n+1];\n        \n        for(auto i:edges)\n        {\n            adlist[i[0]].push_back(make_pair(i[1],i[2]));\n            adlist[i[1]].push_back(make_pair(i[0],i[2]));\n        }\n        \n        \n        dijkatras(n,adlist);\n        \n        \n        return dfs(n,adlist,0);\n        \n        \n        \n        return 0;\n        \n    }\n}
[]