JAVA DP Clean Solution
\n\n# Code\njava []\nclass Solution {\n    int days;\n    int cities;\n    Integer[][]dp;\n    int f(int day, int city, int[][] stayScore, int[][] travelScore) 
\n\n# Code\n```java []\nclass Solution {\n    int days;\n    int cities;\n    Integer[][]dp;\n    int f(int day, int city, int[][] stayScore, int[][] travelScore) {\n        if(day == days) return 0;\n        if(dp[day][city] != null) return dp[day][city];\n        int maxScore = 0;\n        for(int desCity = 0; desCity < cities; desCity++) {\n            int score = 0;\n            if(desCity == city)\n                score = stayScore[day][city];\n            else \n                score = travelScore[city][desCity];\n            maxScore = Math.max(maxScore, score+ f(day+1, desCity, stayScore, travelScore));\n        }\n        return dp[day][city] = maxScore;\n    }\n    public int maxScore(int n, int k, int[][] stayScore, int[][] travelScore) {\n        days = k;\n        cities = n;\n        int maxScore = 0;\n        dp = new Integer[days+1][cities+1];\n        for (int city = 0; city < cities; city++) {\n            maxScore = Math.max(maxScore, f(0, city, stayScore, travelScore));\n        }\n        return maxScore;\n    }\n}\n```
[]