Top down DP | C++
Complexity\n- Time complexity: O(n^2k)\n Add your time complexity here, e.g. O(n) \n\n# Code\ncpp []\nclass Solution {\npublic:\n    int dp[201][201];\n    int 
# Complexity\n- Time complexity: $$O(n^2k)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int dp[201][201];\n    int nn, kk;\n\n    int tdp(int ki, int cc, vector<vector<int>>&ss, vector<vector<int>>&ts){\n        if(ki==kk)return 0;\n        if(dp[ki][cc]!=-1)return dp[ki][cc];\n        int res=0;\n        res=max(res, ss[ki][cc]+tdp(ki+1, cc, ss, ts));\n        for(int i=0;i<nn;i++)res=max(res, ts[cc][i]+tdp(ki+1, i, ss, ts));\n        return dp[ki][cc]=res;\n    }\n\n    int maxScore(int n, int k, vector<vector<int>>& stayScore, vector<vector<int>>& travelScore) {\n        memset(dp, -1, sizeof(dp));\n        nn=n;kk=k;\n        int ans=0;\n        for(int i=0;i<n;i++)ans=max(ans, tdp(0, i, stayScore, travelScore));\n        return ans;\n    }\n};\n```
[]