✅C++ Accepted | Suffix Maxima | Easy⛳
 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 n = grid.size(),
<!-- 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 n = grid.size(), m = grid[0].size();\n        vector<vector<int>> large(n,vector<int>(m));\n        large[n-1][m-1] = grid[n-1][m-1];\n        \n        for(int i=n-2;i>=0;i--) large[i][m-1] = max(large[i+1][m-1],grid[i][m-1]);\n        for(int i=m-2;i>=0;i--) large[n-1][i] = max(large[n-1][i+1],grid[n-1][i]);\n\n        for(int i=n-2;i>=0;i--){\n            for(int j=m-2;j>=0;j--){\n                large[i][j] = max({grid[i][j],large[i+1][j],large[i][j+1]});\n            }\n        }\n        \n        int ans = INT_MIN;\n        for(int i=0;i<n;i++){\n            for(int j=0;j<m;j++){        \n                if(i+1 < n) ans = max(ans,large[i+1][j] - grid[i][j]);\n                if(j+1 < m) ans = max(ans,large[i][j+1] - grid[i][j]);\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']