Easy Java Solution || Dynamic Programing
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    public int maxScore(List<List<Integer>> arr) {\n        int n = arr.size();\n        int m = arr.get(0).size();\n        int dp[][]  = new int[n][m];\n        int ans = -(int)(1e9);\n        for(int j=0; j<m; j++){\n            int diff = -(int)(1e9);\n            for(int k=j+1; k<m; k++){\n                diff = Math.max(diff,arr.get(n-1).get(k)-arr.get(n-1).get(j));\n            }\n            dp[n-1][j] = diff;\n            ans = Math.max(ans,dp[n-1][j]);\n        }\n\n        for(int i=0; i<n; i++){\n            int diff = -(int)(1e9);\n            for(int k=i+1; k<n; k++){\n                diff = Math.max(diff,arr.get(k).get(m-1)-arr.get(i).get(m-1));\n            }\n            dp[i][m-1] = diff;\n            ans = Math.max(ans,dp[i][m-1]);\n        }\n\n        dp[n-1][m-1] = 0;\n\n        for(int i=n-2; i>=0; i--){\n            for(int j=m-2; j>=0; j--){\n                int a = arr.get(i+1).get(j)-arr.get(i).get(j);\n                int b = arr.get(i).get(j+1)-arr.get(i).get(j);\n\n                int x = Math.max(a,a+dp[i+1][j]);\n                int y = Math.max(b,b+dp[i][j+1]);\n                dp[i][j] = Math.max(x,y);\n                ans = Math.max(ans,dp[i][j]);\n            }\n        }\n\n        return ans;\n    }\n}\n```
['Java']