Simple java solution
Complexity\n- Time complexity: O(mn)\n\n- Space complexity: O(mn)\n\n# Code\n\nclass Solution {\n    public int maxScore(List<List<Integer>> grid) {\n        in
# Complexity\n- Time complexity: $$O(m*n)$$\n\n- Space complexity: $$O(m*n)$$\n\n# Code\n```\nclass Solution {\n    public int maxScore(List<List<Integer>> grid) {\n        int m = grid.size(), n = grid.get(0).size();\n        int ans[][] = new int[m][n];\n        ans[m-1][n-1] = grid.get(m-1).get(n-1);\n        for(int i=n-2;i>=0;i--)\n        {\n            ans[m-1][i]=Math.max(ans[m-1][i+1],grid.get(m-1).get(i));\n        }\n        for(int i=m-2;i>=0;i--)\n        {\n            ans[i][n-1]=Math.max(ans[i+1][n-1], grid.get(i).get(n-1));\n        }\n        for(int i=m-2;i>=0;i--)\n        {\n            for (int j=n-2;j>=0;j--)\n            {\n                ans[i][j] = Math.max(grid.get(i).get(j), Math.max(ans[i+1][j], ans[i][j+1]));\n            }\n        }\n        int count = Integer.MIN_VALUE;\n        for(int i=0;i<m;i++)\n        {\n            for(int j=0;j<n;j++)\n            {\n                if(i+1<m)\n                {\n                    count=Math.max(count, ans[i+1][j]-grid.get(i).get(j));\n                }\n                if(j+1<n)\n                {\n                    count=Math.max(count, ans[i][j+1]-grid.get(i).get(j));\n                }\n                \n            }\n        }\n        return count;\n    }\n}\n```
['Java']