Submatrix max minus current corner
Complexity\n- Time complexity:  O(mn)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(mn)\n Add your space complexity here, e.g. O(n) \n\n#
# Complexity\n- Time complexity:  $$O(mn)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(mn)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int m;\n    int n;\n\n    void recurse(vector<vector<int>>& dp, vector<vector<int>>& grid, int& res,\n                 int i, int j) {\n        if (i >= m || j >= n) {\n            return;\n        }\n\n        if (dp[i][j] != -1) {\n            return;\n        }\n\n        int rightValue = INT_MIN, downValue = INT_MIN;\n        if (j + 1 < n) {\n            recurse(dp, grid, res, i, j + 1);\n            rightValue = dp[i][j + 1];\n        }\n\n        if (i + 1 < m) {\n            recurse(dp, grid, res, i + 1, j);\n            downValue = dp[i + 1][j];\n        }\n\n        if (i == m - 1 && j == n - 1) {\n            dp[i][j] = grid[i][j];\n        } else {\n            dp[i][j] = max(grid[i][j], max(rightValue, downValue));\n            res = max(res, max(rightValue, downValue) - grid[i][j]);\n        } \n    }\n\n    int maxScore(vector<vector<int>>& grid) {\n        m = grid.size();\n        n = grid[0].size();\n        vector<vector<int>> dp(m, vector<int>(n, -1));\n        int res = INT_MIN;\n        recurse(dp, grid, res, 0, 0);\n        return res;\n    }\n};\n\n```
['C++']