Easy C++ Solution || (Recursion + Memoization) ✅✅
Code\n\nclass Solution {\npublic:\n    int helper(vector<vector<int>>& grid,int i,int j,int n,int m,vector<vector<int>> &dp){\n        if(i==(n-1) && j==(m-1)){
# Code\n```\nclass Solution {\npublic:\n    int helper(vector<vector<int>>& grid,int i,int j,int n,int m,vector<vector<int>> &dp){\n        if(i==(n-1) && j==(m-1)){\n            return dp[i][j]=0;\n        }\n        int ans=-1e6;\n        if(dp[i][j]!=-1e6){\n            return dp[i][j];\n        }\n        if((i+1)<n){\n            ans=max(ans,grid[i+1][j]-grid[i][j]+helper(grid,i+1,j,n,m,dp));\n            ans=max(ans,grid[i+1][j]-grid[i][j]+helper(grid,n-1,m-1,n,m,dp));\n        }\n        if((j+1)<m){\n            ans=max(ans,grid[i][j+1]-grid[i][j]+helper(grid,i,j+1,n,m,dp));\n            ans=max(ans,grid[i][j+1]-grid[i][j]+helper(grid,n-1,m-1,n,m,dp));\n        }\n        return dp[i][j]=ans;\n    }\n    int maxScore(vector<vector<int>>& grid) {\n        int n=grid.size();\n        int m=grid[0].size();\n        vector<vector<int>> dp(n,vector<int>(m,-1e6));\n        helper(grid,0,0,n,m,dp);\n        int ans=INT_MIN;\n        for(int i=0;i<n;i++){\n            for(int j=0;j<m;j++){\n                if(i==(n-1) && j==(m-1)){\n                    continue;\n                }\n                ans=max(ans,dp[i][j]);\n            }\n        }\n        return ans;\n    }\n};\n```
['Dynamic Programming', 'Recursion', 'Memoization', 'C++']