Java | DP + Memo | 2 states | Time 100% | Space 100%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public int maxScore(int n, int k, int[][] stayScore, int[][] travelScore) {\n\t\tint[][] dp = new int[n + 1][k + 1];\n\t\treturn f(-1, 0, n, k, stayScore, travelScore, dp);\n\t}\n\n\tprivate int f(int curr, int day, int n, int k, int[][] stayScore, int[][] travelScore, int[][] dp) {\n\t\tif (day == k) return 0;\n\n\t\tif (dp[curr + 1][day] != 0) return dp[curr + 1][day] - 1;\n\n\t\tint max = curr == -1 ? 0 : stayScore[day][curr] + f(curr, day + 1, n, k, stayScore, travelScore, dp);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (i != curr)\n\t\t\t\tmax = Math.max(max, curr == -1 ? f(i, day, n, k, stayScore, travelScore, dp) : travelScore[curr][i] + f(i, day + 1, n, k, stayScore, travelScore, dp));\n\t\t}\n        dp[curr + 1][day] = max + 1;\n\t\treturn max;\n\t}\n}\n```
['Dynamic Programming', 'Recursion', 'Memoization', 'Java']