Simple Javascript dp
Code\njavascript []\n/**\n * @param {number} n\n * @param {number} k\n * @param {number[][]} stayScore\n * @param {number[][]} travelScore\n * @return {number}\
# Code\n```javascript []\n/**\n * @param {number} n\n * @param {number} k\n * @param {number[][]} stayScore\n * @param {number[][]} travelScore\n * @return {number}\n */\nconst maxScore = (n, k, stayScore, travelScore) => {\n\n    // 200 cities and 200 days. create a cache and initialize it.\n    const dp = new Array(200).fill().map(() => Array(200).fill(-1));\n    let res = 0;\n\n    const calculateScore = (currentCity, currentDay) => {\n\n        // exit\n        if (currentDay === k) return 0;\n\n        // calculation already in cache.\n        if (dp[currentDay][currentCity] !== -1) return dp[currentDay][currentCity];\n\n        // case 1: we stay at our current city\n        let max = stayScore[currentDay][currentCity] + calculateScore(currentCity, currentDay + 1);\n\n\n        // case 2: we go to a different city\n        for (let nextCity = 0; nextCity < n; nextCity++) {\n\n            // otherwise means we are staying\n            if (nextCity !== currentCity) {\n                let travelPoints = travelScore[currentCity][nextCity] + calculateScore(nextCity, currentDay + 1);\n                max = Math.max(max, travelPoints);\n            }\n        }\n        dp[currentDay][currentCity] = max;\n        return max;\n\n    };\n\n    for (let city = 0; city < n; city++) {\n        res = Math.max(res, calculateScore(city, 0));\n    }\n\n    return res;\n};\n\n```
[]