DP
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: O(mxn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(mxn)\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 m = grid.size();\n        int n = grid[0].size();\n        vector<vector<int>> dp(m, vector<int>(n, INT_MIN));\n        dp[0][0] = 0;\n        \n        for (int i = 0; i < m; i++) {\n            for (int j = 0; j < n; j++) {\n                if (i == 0 && j == 0)\n                    continue;\n                // left\n                if (j - 1 >= 0) {\n                    int c2 = grid[i][j];\n                    int c1 = grid[i][j-1];\n                    int optimalPathFromLeft = dp[i][j-1];\n\n                    dp[i][j] = max(dp[i][j], max(c2 - c1, c2 - c1 + optimalPathFromLeft));\n                }\n\n                // upwards\n                if (i - 1 >= 0) {\n                    int c2 = grid[i][j];\n                    int c1 = grid[i-1][j];\n                    int optimalPathFromUp = dp[i-1][j];\n\n                    dp[i][j] = max(dp[i][j], max(c2 - c1, c2 - c1 + optimalPathFromUp));\n                }\n                ans = max(ans, dp[i][j]);\n            }\n        }\n        return ans;\n    }\n};\n\n```
['Dynamic Programming', 'Matrix', 'C++']