EASY DP RECURSIVE DP JAVA
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 {\n    Integer[][] dp;\n    public int maxScore(List<List<Integer>> grid) {\n        int n = grid.size();\n        int m = grid.get(0).size();\n        int ans = -100000;\n        dp = new Integer[n][m];\n        for(int i = 0;i<grid.size();i++){\n            for(int j = 0;j<grid.get(0).size();j++){\n                if(i<n-1&&j<m-1){\n                ans = Math.max(ans,Math.max(grid.get(i+1).get(j)-grid.get(i).get(j)+solve(i+1,j,grid,n,m),grid.get(i).get(j+1)-grid.get(i).get(j)+solve(i,j+1,grid,n,m)));\n                }else if(i==n-1&&j<m-1){\n                    ans = Math.max(ans,grid.get(i).get(j+1)-grid.get(i).get(j)+solve(i,j+1,grid,n,m));\n                }else if(j==m-1&&i<n-1){\n                    ans = Math.max(grid.get(i+1).get(j)-grid.get(i).get(j)+solve(i+1,j,grid,n,m),ans);\n                }\n            }\n        }\n        return ans;\n    }\n    public int solve(int row, int col, List<List<Integer>> grid, int n, int m){\n        if(dp[row][col]!=null)\n            return dp[row][col];\n        int ans = 0;\n        int a = 0;\n        int b = 0;\n        \n        if(row+1<n){\n            a = Math.max(a,grid.get(row+1).get(col)-grid.get(row).get(col)+solve(row+1,col,grid,n,m));\n        }\n        if(col+1<m){\n             b = Math.max(b,grid.get(row).get(col+1)-grid.get(row).get(col)+solve(row,col+1,grid,n,m));\n        }\n        return dp[row][col] =  Math.max(a,b);\n    }\n}\n```
['Array', 'Dynamic Programming', 'Matrix', 'Java']