Using Djikstra's To find the shortest paths and then conditional DFS to reach 1.
If you find it Helpful, Do upvote! Thanks! Cheers. This is a good one.\n\nclass Solution {\npublic: \n    \n    /*\n        This is a typical dp on graphs probl
If you find it Helpful, Do upvote! Thanks! Cheers. This is a good one.\n```\nclass Solution {\npublic: \n    \n    /*\n        This is a typical dp on graphs problem where we first find out the shortest routes from n to every other node, then we perform dfs on\n        graph starting from node n,such that we go to next dfs only if the corresponding edge\'s distance is greater than now node\'s.\n        We continue this untill we get to 1, and in the way we look for strictly increasing paths as well.\n        We use DP here as from current node, there can be multiple strictly increasing paths to reach 1. \uD83D\uDE2A\n    */\n    \n    int dfs(vector<pair<int,int>> edge[],vector<int> &distance,int n,vector<int> &dp){\n        int inf=1e9+7;\n        if(n==1)\n            return 1;\n        if(dp[n]!=-1)\n            return dp[n];\n        int ans=0;\n        for(auto it:edge[n]){\n            if(distance[it.first]>distance[n]){\n                ans+=((dfs(edge,distance,it.first,dp))%(inf))%inf;\n                ans=ans%inf;\n            }\n        }\n        return dp[n]=ans%inf;\n    }\n    \n    void djikstra(vector<pair<int,int>> edge[],vector<int> &distance,int n){\n        distance[n]=0;\n        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;\n        pq.push({0,n});\n        while(!pq.empty()){\n            pair<int,int> p=pq.top();\n            pq.pop();\n            if(p.first > distance[p.second])\n                continue;\n            for(auto it:edge[p.second]){\n                if(distance[it.first] > distance[p.second]+it.second){\n                    distance[it.first]=distance[p.second]+it.second;\n                    pq.push({distance[it.first],it.first});\n                }\n            }\n        }\n    }\n    \n    int countRestrictedPaths(int n, vector<vector<int>>& edges) {\n        vector<int> distance(n+1,INT_MAX);\n        vector<pair<int,int>> edge[n+1];\n        for(auto it:edges){\n            edge[it[0]].push_back({it[1],it[2]});\n            edge[it[1]].push_back({it[0],it[2]});\n        }\n        djikstra(edge,distance,n);\n        vector<int> dp(n+1,-1);\n        return dfs(edge,distance,n,dp);\n        return 0;\n    }\n};\n```
[]