Q1575 Accepted C++ ✅ Rec->Memo TopDown DP | Easiest
CRUX\n1) Start & Finsh must be present and anypath can be used till fuel is >=0.\n\nRecursion + Storing = Memoization\n\nclass Solution {\npublic:\n    int mod 
CRUX\n1) Start & Finsh must be present and anypath can be used till fuel is >=0.\n\n*Recursion + Storing = Memoization*\n```\nclass Solution {\npublic:\n    int mod = 1e9+7;\n    int solve(int s,int f,int fuel,vector<int>&loc,vector<vector<int>>&dp){\n        int count = 0;\n        if(s == f)\n            count++;\n        \n        if(dp[s][fuel] != -1)\n            return dp[s][fuel];\n        \n        for(int i=0;i<loc.size();i++){\n            if(i!=s && abs(loc[i]-loc[s])<=fuel){ // Check that start doesn\u2019t coincide and Fuel is non-negative\n                count += solve(i,f,fuel-abs(loc[i]-loc[s]),loc,dp);\n                count = count%mod; // Apply Mod for large values of count \n            }\n        }\n        return dp[s][fuel] = count; // Store and Return\n    }\n    int countRoutes(vector<int>& locations, int start, int finish, int fuel) {\n        int n = locations.size();\n        vector<vector<int>> dp(n,vector<int>(fuel+1,-1));\n        return solve(start,finish,fuel,locations,dp);\n    }\n};\n```
['Dynamic Programming', 'Recursion', 'Memoization', 'C']