Java Tabulated DP
Complexity\n- Time complexity: O(n * n * k)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n * k)\n Add your space complexity here, e.g. O
# Complexity\n- Time complexity: O(n * n * k)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n * k)\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        int max = 0;\n\n        int[][] dp = new int[k+1][n+1];\n\n        //current day\n        for (int day = 1; day <= k; day++){\n            //city we are travelling / staying at\n            for (int city = 1; city <= n; city++){\n                //check if we travel from each prev city\n                for (int i = 1; i <= n; i++){\n                    int additionalScore = 0;\n                    //check if we started at same city and stayed\n                    if (i == city) additionalScore += stayScore[day-1][city-1];\n                    //if we traveled from diff city to here\n                    else additionalScore += travelScore[i-1][city-1];\n                    \n                    dp[day][city] = Math.max(dp[day][city], dp[day-1][i] + additionalScore);\n                }\n                max = Math.max(max, dp[day][city]);\n            }\n        }\n\n\n        return max;\n    }\n}\n```
[]