DP || Super Simple || C++
Code\ncpp []\nclass Solution \n{\npublic:\n    int f(int curr, int i, int n, int k, vector<vector<int>>& stayScore, vector<vector<int>>& travelScore, vector<vec
# Code\n```cpp []\nclass Solution \n{\npublic:\n    int f(int curr, int i, int n, int k, vector<vector<int>>& stayScore, vector<vector<int>>& travelScore, vector<vector<int>> &dp)\n    {\n        if(i==k) return 0;\n        if(dp[curr][i]!=-1) return dp[curr][i];\n        int stay=stayScore[i][curr]+f(curr,i+1,n,k,stayScore,travelScore,dp);\n        int travel=0;\n        for(int dest=0; dest<n; dest++)\n        {\n            travel=max(travel, travelScore[curr][dest]+f(dest,i+1,n,k,stayScore,travelScore,dp));\n        }\n        return dp[curr][i]=max(stay,travel);\n    }\n    int maxScore(int n, int k, vector<vector<int>>& stayScore, vector<vector<int>>& travelScore) \n    {\n        int ans=0;\n        vector<vector<int>> dp(n+1,vector<int> (k+1,-1));\n        for(int x=0; x<n; x++)\n        {\n            ans=max(ans,f(x,0,n,k,stayScore,travelScore,dp));\n            dp.resize(n+1,vector<int> (k+1,-1));\n        }\n        return ans;\n    }\n};\n```
[]