RECURSION || EXPLAINED || NOT OPTI. BUT BEGINNER FRIENDLY
Intuition\nSo basically we have two conditions\n1. stay at current city\n2. travel to another city\n\nin both conditions we will reduce k (no of days he can tra
# Intuition\nSo basically we have two conditions\n`1. stay at current city`\n`2. travel to another city`\n\nin both conditions we will reduce k (no of days he can travel)\nif we stay in same city-> our current city doesnt change\nif we travel -> the travelled city becomes our current city\n`what is i variable here?` \nso basically we are not given any starting point so we can start from anywhere so i is the current index we are at\n\nreturn the max from each starting point we get and then find maximum\n\n\n# Code\n```python3 []\nclass Solution:\n    def maxScore(self, n: int, k: int, stayScore: List[List[int]], travelScore: List[List[int]]) -> int:\n        @cache\n        def recur(i, k, curr):\n            if k <= 0:\n                return 0\n            result = float(\'-inf\')\n            for j in range(n):\n                if j == curr:\n                    points = stayScore[i][curr] # tarveller stay\n                else:\n                    points = travelScore[curr][j] # traveller travel\n                result = max(result, points + recur(i+1, k-1, j))  \n            return result\n        maxi = float(\'-inf\')\n        for i in range(n): # choose any starting pint\n            maxi = max(maxi, recur(0, k, i)) # choose starting city\n        return maxi\n\n        \n```
[]