Easy Python Explanation + Video 🔥🔥🔥🔥🔥🔥🔥
You can check out my YouTube channel (click on my Leetcode profile, there is a link to my YouTube channel), I explain in details a solution that passes! Hope th
You can check out my YouTube channel (click on my Leetcode profile, there is a link to my YouTube channel), I explain in details a solution that passes! Hope that can help ;)\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        # dp[i][j] => maximum score you can get if you are in city i, and it\'s the jth day\n        # We will start with the last day.\n        dp: list[list[int]] = [[0 for _ in range(k)] for _ in range(n)]\n\n        # Initialization\n        for i in range(n):\n            # Staying\n            dp[i][k-1] = max(\n                dp[i][k-1],\n                stayScore[k-1][i]\n            )\n            for other_city in range(n):\n                # Travelling\n                if i != other_city:\n                    dp[i][k-1] = max(\n                        dp[i][k-1],\n                        travelScore[i][other_city]\n                    )\n\n        # Transitions\n        for j in range(k-2, -1, -1):\n            for i in range(n):\n                # Staying\n                dp[i][j] = max(\n                    dp[i][j],\n                    stayScore[j][i] + dp[i][j+1]\n                )\n                for other_city in range(n):\n                    # Travelling\n                    if i != other_city:\n                        dp[i][j] = max(\n                            dp[i][j],\n                            travelScore[i][other_city] + dp[other_city][j+1]\n                        )\n\n        return max(dp[i][0] for i in range(n))\n\n```
[]