Maximum Points Tourist Can Earn | DP | C++ Easy
\n\n# Complexity\n- Time complexity: O(kn)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(kn)\n Add your space complexity here, e.g. O(n) 
\n\n# Complexity\n- Time complexity: $$O(k*n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(k*n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int helper(vector<vector<int>>& stayScore,vector<vector<int>>& travelScore, int city, int day, vector<vector<int>> &memo){\n        if(day == stayScore.size()) return 0;\n\n        if(memo[day][city] != -1) return memo[day][city];\n        int ans = stayScore[day][city] + helper(stayScore, travelScore, city, day+1, memo);\n        for(int i = 0; i<travelScore.size(); i++){\n            ans = max(travelScore[city][i] + helper(stayScore, travelScore, i, day+1, memo), ans);\n        }\n\n        return memo[day][city] = ans;\n    }\n    int maxScore(int n, int k, vector<vector<int>>& stayScore, vector<vector<int>>& travelScore) {\n        int ans = 0;\n        vector<vector<int>> memo(200, vector<int>(200, -1));\n        for(int i = 0; i<n; i++){\n            ans = max(ans, stayScore[0][i] + helper(stayScore, travelScore, i, 1, memo));\n        }\n\n        for(int i = 0; i<n; i++){\n            for(int j = 0; j<n; j++){\n                ans = max(ans, travelScore[i][j] + helper(stayScore, travelScore, j, 1, memo));\n            }\n        }\n\n        return ans;\n    }\n};\n```
[]