Easy Iterative Dp Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maxScore(vector<vector<int>>& grid) {\n        int ans = INT_MIN;\n        int n = grid.size(), m = grid[0].size();\n        vector<vector<int> > dp(n, vector<int> (m, -1e8));\n        for(int i = 0; i < n; i++){\n            for(int j = 0; j < m; j++){\n                // come from left\n                for(int k = 0; k < j; k++){\n                    dp[i][j] = max(dp[i][j], ((dp[i][k] == -1e8) ? 0 : max(0, dp[i][k])) + grid[i][j]-grid[i][k]);\n                }\n                // come from top\n                for(int k = 0; k < i; k++){\n                    dp[i][j] = max(dp[i][j], ((dp[k][j] == -1e8) ? 0 : max(0, dp[k][j])) + grid[i][j]-grid[k][j]);\n                }\n                ans = max(ans, dp[i][j]);\n            }\n        }\n\n        return ans;\n    }\n};\n```
['Array', 'Dynamic Programming', 'Matrix', 'C++']