Easy  memoization approach || C++ 🔥🔥
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n1. solvemaxScore Func
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n1. **solvemaxScore Function**: This function is a helper function that uses recursion and dynamic programming to solve the problem.\n\n    - It takes four parameters: `grid` (the 2D grid), `i` and `j` (the current cell coordinates), and `dp` (a 2D array for memoization).\n    - If `i` or `j` is out of the grid\'s bounds, it returns `INT_MIN` (the smallest possible integer), indicating an invalid state.\n    - If the current cell `(i, j)` has been visited before (i.e., `dp[i][j]` is not `INT_MIN`), it returns the stored value.\n    - It calculates two possible scores `take1` and `take2` for the two possible moves: moving right to `(i, j+1)` and moving down to `(i+1, j)`. The score for a move is calculated as the difference between the value of the destination cell and the current cell, plus the maximum score that can be obtained from the destination cell (if it\'s positive).\n    - It stores the maximum of `take1` and `take2` in `dp[i][j]` and returns this value.\n\n2. **maxScore Function**: This is the main function that solves the problem.\n\n    - It initializes the `dp` array (`fvalue`) with `INT_MIN`.\n    - It calls the `solvemaxScore` function to calculate the maximum score from the top-left corner `(0, 0)`.\n    - It then iterates over the `dp` array to find the maximum score among all cells and returns this value.\n\nThe code uses `INT_MIN` as a special value to indicate that a cell in the `dp` array has not been visited yet, and also as an initial value for the maximum score. The `maxScore` function returns the maximum score that can be obtained by moving from the top-left corner to the bottom-right corner of the grid, according to the rules defined in the `solvemaxScore` function.\n\n\n\n\n# Complexity\n- Time complexity:O(m*n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(m*n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n  \n    int solvemaxScore(vector<vector<int>>&grid , int i, int j, vector<vector<int>>&dp)\n    {\n        if(i>=grid.size() || j>=grid[0].size())\n        {\n            return INT_MIN;\n        }\n        \n        if(dp[i][j]!=INT_MIN)\n        {\n            return dp[i][j];\n        }\n        \n        int ans = INT_MIN;\n        int take1=INT_MIN,take2=INT_MIN;\n        \n        if(i+1<grid.size())\n        {\n         take2 = grid[i+1][j] - grid[i][j]  + max(0, solvemaxScore(grid,i+1,j,dp));\n        //  cout<<"take2 "<<"{i,j}"<<i<<","<<j<<" "<<take2<<endl;\n        }\n        if(j+1<grid[0].size())\n        {\n         take1 = grid[i][j+1] - grid[i][j] + max(0,solvemaxScore(grid,i,j+1,dp));\n        //  cout<<"take1 "<<"{i,j}"<<i<<","<<j<<" "<<take1<<endl;\n        }\n        \n        \n        dp[i][j] = max(take1,take2);\n        return dp[i][j];\n    }\n    \n    int maxScore(vector<vector<int>>& grid) {\n        int r = grid.size();\n        int c = grid[0].size();\n        int maxi=INT_MIN;\n\n        vector<vector<int>>fvalue(grid.size()+1,vector<int>(grid[0].size()+1,INT_MIN));\n        int ans = solvemaxScore(grid,0,0,fvalue);\n        \n        int ans1 = INT_MIN;\n       //here we are finding the maximum value from the dp ans storing it in the answer (ans1)\n        for(int i=0;i<fvalue.size();i++)\n        {\n            for(int j=0;j<fvalue[0].size();j++)\n            {\n                ans1=max(ans1,fvalue[i][j]);\n            }\n            // cout<<endl;\n        }\n\n        return ans1;\n        \n    }\n};\n```
['C++']