Beats >70% ||  Simple approach || Memoization || Small and clean code
Intuition\nThe Intuition is to count all possible routes from a start city to a finish city, given a certain amount of fuel. It uses a recursive approach with m
# Intuition\nThe Intuition is to count all possible routes from a start city to a finish city, given a certain amount of fuel. It uses a recursive approach with memoization to optimize the computation.\n\n- Space complexity: O(m*n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\nconst int mod = 1000000007;\n\n    int count(vector<int>& locations, int start, int finish, int fuel, int n, vector<vector<int>> &dp) {\n\n        int ways=0; // initialize total ways as zero\n        if (start == finish) ways++; // if reached finish line increase count as we can again come to finish location if there is fuel left that\'s why we are not returning 1 \n        if (fuel < 0) \n            return 0; // if fuel is finished return 0 as no path from here now \n        if (dp[start][fuel] != -1)\n            return dp[start][fuel]; // return already stored value \n\n\n        for (int ind = 0; ind < n; ind++) {\n            if (ind == start)\n                continue;  // to avoid the same start index \n\n\n            // if we can go to next location then apply recursion on that city and add it to ways \n            if (fuel >= abs(locations[ind] - locations[start])) {\n                ways = (ways + count(locations, ind, finish, fuel - abs(locations[start] - locations[ind]), n, dp)) % mod;  \n            } \n        }\n\n        return dp[start][fuel] = ways; // return the ways\n    }\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)); // declare dp array\n        return count(locations, start, finish, fuel,\xA0n,\xA0dp);\n\xA0\xA0\xA0\xA0}\n};\n\n```
['C++']