[C++] Intuition - Consider only a single step
Intuition - \nLet\'s consider a series a->b, b->c, c->d, d->e. The total sum then would be b-a + c-b + d-c + e-d , which is finally  same as e-a. So the differe
**Intuition** - \nLet\'s consider a series a->b, b->c, c->d, d->e. The total sum then would be b-a + c-b + d-c + e-d , which is finally  same as e-a. So the difference of ending and starting points would add to the result  and the ending point should be the maximum value in the subgrid  ` grid[i...m][j...n]`. \n\n**Approach** - \n\n`dp[i][j]` stores the maximum value in the subgrid ` grid[i...m][j...n]` and for every ` grid[i][j]` consider it as a starting point and update the result.\n\n**Code [C++]**\n```\nclass Solution {\npublic:\n    int maxScore(vector<vector<int>>& grid) {\n        \n        int m=grid.size(),n=grid[0].size();\n        \n        //dp[i][j] -> maximum element in the subgrid [i..m][j..n]\n        vector<vector<int>> dp(m,vector<int>(n,INT_MAX));\n        \n        int res=INT_MIN;\n\n        for(int i=m-1;i>=0;i--)\n        {\n            for(int j=n-1;j>=0;j--)\n            {\n                \n                int maxi=INT_MIN;\n                \n                if(j+1<n)\n                    maxi=max(maxi, dp[i][j+1]);\n                if(i+1<m)\n                    maxi=max(maxi, dp[i+1][j]);\n                \n                //no bottom and right element \n                if(maxi==INT_MIN){\n                    \n                    dp[i][j]=grid[i][j];\n                    continue;\n                }\n                \n                //update the result \n                res=max(res, maxi - grid[i][j]);\n                \n                //update the maximum element in the subgrid\n                dp[i][j]=max(maxi, grid[i][j]);\n            }\n        }\n        \n        return res;\n        \n    }\n    \n};\n```\n\n**Please upvote if you like the solution**\n
[]