Easy Memoization Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nI know it\'s a weird way, but it still works.\n# Approach\n Describe your approach to s
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nI know it\'s a weird way, but it still works.\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```java []\nclass Solution {\n    Integer[][][] dp;\n    public int maxScore(List<List<Integer>> grid) {\n        dp = new Integer[grid.size()][grid.get(0).size()][2];\n        int max = Integer.MIN_VALUE;\n        for(int i = 0; i<grid.size(); i++){\n            for(int j = 0; j<grid.get(0).size(); j++){\n               max = Math.max(max,f(grid,i,j,1)); \n            }\n        }\n        return max;\n    }\n    public int f(List<List<Integer>> grid,int i,int j,int m){\n        if(dp[i][j][m] != null){\n            return dp[i][j][m];\n        }\n        if(m == 1){\n            int down = Integer.MIN_VALUE;\n            int right = Integer.MIN_VALUE;\n            if(i < grid.size() - 1){\n                down = f(grid,i+1,j,0)-grid.get(i).get(j);\n            }\n            if(j < grid.get(0).size() - 1){\n                right = f(grid,i,j+1,0)-grid.get(i).get(j);\n            }\n            return dp[i][j][m] = Math.max(down,right);\n        }\n        int down = grid.get(i).get(j);\n        int right = grid.get(i).get(j);\n        if(i < grid.size() - 1){\n            down = Math.max(down,down + f(grid,i+1,j,m)-grid.get(i).get(j));\n        }\n        if(j < grid.get(0).size() - 1){\n            right = Math.max(right,right + f(grid,i,j+1,m)-grid.get(i).get(j));\n        }\n        return dp[i][j][m] = Math.max(down,right);\n    }\n}\n```
['Array', 'Dynamic Programming', 'Recursion', 'Memoization', 'Matrix', 'C++', 'Java', 'Python3']