Memo dp
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```java []\nclass Solution {\n    private Integer dp[][];\n    \n    public int maxScore(List<List<Integer>> grid) {\n        int m = grid.size(), n = grid.get(0).size();\n        dp = new Integer[m][n];\n        int max = Integer.MIN_VALUE;\n        \n        for (int i = 0; i < m; i++) {\n            for (int j = 0; j < n; j++) {\n                int temp = getMaxDiff(i, j, m, n, grid);\n                max = Math.max(temp, max);\n            }\n        }\n        \n        return max;\n    }\n    \n    public int getMaxDiff(int row, int col, int m, int n, List<List<Integer>> grid) {\n        if (row >= m || col >= n) return Integer.MIN_VALUE;\n        if (dp[row][col] != null) return dp[row][col];\n        \n        int max = Integer.MIN_VALUE;\n        int ele = grid.get(row).get(col);\n        \n        if (row + 1 < m)    \n            max = Math.max(max, grid.get(row + 1).get(col) - ele + Math.max(0, getMaxDiff(row + 1, col, m, n, grid)));\n        \n        if (col + 1 < n)    \n            max = Math.max(max, grid.get(row).get(col + 1) - ele + Math.max(0, getMaxDiff(row, col + 1, m, n, grid)));\n        \n        return dp[row][col] = max;\n    }\n}\n\n```
['Java']