Beats 99.85% C++ Solution
Intuition\nFinfing min upto index i,j and reducing it from grid[i][j] and iterating to find max out of all such differences \n\n# Approach\nIterate from 0,0 to 
# Intuition\nFinfing min upto index i,j and reducing it from grid[i][j] and iterating to find max out of all such differences \n\n# Approach\nIterate from 0,0 to i,j notice upto this point all i-1,j and i,j-1 had been already calculated so can esily use them\nso\n minval(i,j) = min( minval( i-1 , j ), minval( i, j-1 ))\nwhere minval(i,j) represents minvalue upto i,j\n# Complexity\n- Time complexity:\n$$O(n*m)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nint speedup = []{ios::sync_with_stdio(0); cin.tie(0); return 0;}();\nclass Solution {\n\npublic:\n    int maxScore(vector<vector<int>>& grid) {\n        int ans = INT_MIN;\n        for(int i = 0; i < grid.size(); ++i){\n            for(int j = 0; j < grid[0].size(); ++j){\n                int mn = INT_MAX;\n                if(i == 0 && j == 0) continue;\n                if(i != 0) mn = min(mn, grid[i-1][j]);\n                if(j != 0) mn = min(mn, grid[i][j-1]);\n                ans = max(ans, grid[i][j] - mn);\n                grid[i][j] = min(grid[i][j], mn);\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']