[Python] dfs + cache
python\nclass Solution:\n    def countRoutes(self, locations: List[int], start: int, finish: int, fuel: int) -> int:\n        \n        @cache\n        def dp(i
```python\nclass Solution:\n    def countRoutes(self, locations: List[int], start: int, finish: int, fuel: int) -> int:\n        \n        @cache\n        def dp(i, f):            \n            r = int(i == finish)\n\n            for j in range(len(locations)):\n                if j != i and abs(locations[i] - locations[j]) <= f:\n                    r += dp(j, f - abs(locations[i] - locations[j]))\n\n            return r % (10**9 + 7)\n        \n        return dp(start, fuel) % (10**9 + 7)\n```
['Depth-First Search', 'Python']