Easy DP | Beats 100.00% | Tabulation | C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n\n# Complexity\n- Time complexity: O(n^2k)\n Add your time complexity here, e.g. O(n)
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n\n# Complexity\n- Time complexity: $$O(n^2*k)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n*k)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int maxScore(int n, int k, vector<vector<int>>& stayScore, vector<vector<int>>& travelScore) {\n        vector<vector<int>> dp(k+1,vector<int>(n,0));\n\n        for(int i = 1; i < k+1; i++){\n            for(int j = 0; j < n; j++){\n                if(i == 0){\n                    dp[i][j] = 0;\n                }else{\n                    int mx = INT_MIN;\n                    for(int kk = 0; kk < n; kk++){\n                        if(kk == j){\n                            mx = max(mx,dp[i-1][j] + stayScore[i-1][j]);\n                        }else{\n                            mx = max(mx,dp[i-1][kk] + travelScore[kk][j]);\n                        }\n                    }\n                    dp[i][j] = mx;\n                }\n            }\n        }\n        int mx = 0;\n        for (int i = 0; i < n; i++) {\n            mx = max(mx, dp[k][i]);\n        }\n        return mx;\n\n    }\n};\n```
[]