[Python] Simple memoization solution
\nclass Solution:\n    def countRoutes(self, locations: List[int], start: int, finish: int, fuel: int) -> int:\n        MOD = (10**9 + 7)\n        \n        @lr
```\nclass Solution:\n    def countRoutes(self, locations: List[int], start: int, finish: int, fuel: int) -> int:\n        MOD = (10**9 + 7)\n        \n        @lru_cache(None)\n        def dp(start, fuel):\n            if fuel < 0: return\n            \n            ans = 0\n            if start == finish:\n                ans += 1\n            \n            for idx, i in enumerate(locations):\n                cost = fuel - abs(i - locations[start])\n                if idx != start and cost >= 0:\n                    ans += dp(idx, cost)\n            return ans % MOD\n        return dp(start, fuel) % MOD\n```
[]