C++ BACKTRACKING DP RECURSIVE MEMOIZATION
```\n//classical src to destination dp using backtracking then mempoize it\nclass Solution {\npublic:\n    int mod = 1000000007;\n    vector>> g;\n    vector di
```\n//classical src to destination dp using backtracking then mempoize it\nclass Solution {\npublic:\n    int mod = 1000000007;\n    vector<vector<pair<int,int>>> g;\n    vector<int> dis;\n    vector<bool> vis;\n    vector<int> dp;\n     int fun(int src,int des){\n         if(src == des) return 1;\n         // vis[src] = true;\n         if(dp[src] != -1) return dp[src];\n         int ans = 0;\n         for(auto nbr : g[src]){\n             int v = nbr.first;\n             int w = nbr.second;\n             if(vis[v] == false and dis[src] > dis[v]){\n                 vis[v] = true;\n                 ans = (ans%mod + (fun(v,des))%mod)%mod;\n                 vis[v] = false;\n             }\n         }\n         return dp[src] = ans;\n         \n     }\n    \n    int countRestrictedPaths(int n, vector<vector<int>>& e) {\n        g = vector<vector<pair<int,int>>> (n+1);\n        dis = vector<int> (n+1,INT_MAX);\n        vis = vector<bool> (n+1,false);\n        \n        for(int i=0;i<e.size();i++){\n            int u = e[i][0];\n            int v = e[i][1];\n            int w = e[i][2];\n            g[u].push_back({v,w});\n            g[v].push_back({u,w});\n        }\n        \n        \n        set<pair<int,int> > s;\n        s.insert({0,n});\n        dis[n] = 0;\n        while(!s.empty()){\n            auto cur = *(s.begin());\n            int u = cur.second;\n            int dd = cur.first;\n            s.erase(s.begin());\n            if(vis[u]) continue;\n            vis[u] = true;\n            \n            for(auto nbr : g[u]){\n                int v = nbr.first;\n                int w = nbr.second;\n                // cout<<v<<" "<<w<<endl;\n                if(vis[v] == false and dis[v] > dd + w){\n                    dis[v] = dd + w;\n                    s.insert({dis[v],v});\n                }\n            }\n        }\n        vis = vector<bool> (n+1,false);\n        // for(int i=1;i<=n;i++) cout<<dis[i]<<" ";\n        vis[1] = true;\n        dp = vector<int> (n+1,-1);\n        return fun(1,n);\n        \n    }\n};
['Dynamic Programming', 'Backtracking', 'Depth-First Search']