Using Maximum element || Esay || Understandable
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        vector<vector<int>> ans(grid.size(),vector<int> (grid[0].size(),INT_MIN));\n        int s = INT_MIN;\n        for(int i=0;i<grid.size();i++){\n            s = INT_MIN;\n            for(int j=grid[0].size()-1;j>=0;j--){\n                \n                s = max(s,grid[i][j]);\n                ans[i][j] = s;\n            }\n        }\n        s = INT_MIN;\n        for(int i=0;i<ans[0].size();i++){\n            s = INT_MIN;\n            for(int j=ans.size()-1;j>=0;j--){\n                \n                s = max(s,ans[j][i]);\n                ans[j][i] = max(s,ans[j][i]);\n            }\n        }\n        int fans = INT_MIN;\n        for(int i=0;i<grid.size();i++){\n            for(int j=0;j<grid[0].size();j++){\n                cout<<ans[i][j]<<" ";\n                if(i<grid.size()-1){\n                    if(ans[i][j] == ans[i+1][j]){\n                        fans = max(fans,ans[i][j] - grid[i][j]);\n                    }else{\n                        fans = max(fans,ans[i+1][j] - grid[i][j]);\n                    }\n                }\n                \n                if(j<grid[0].size()-1){\n                    if(ans[i][j] == ans[i][j+1]){\n                        fans = max(fans,ans[i][j] - grid[i][j]);\n                    }else{\n                        fans = max(fans,ans[i][j+1] - grid[i][j]);\n                    }\n                }\n                \n            }\n            // cout<<endl;\n        \n        }\n        return fans;\n    }\n};\n```
['C++']