[JAVA] Easy and Clean DP (Tabulation) Solution
Time Complexity - O(N^2)\nSpcae Complexity - O(N^2)\nRuntime - 37ms - Faster than 90.16%\n.\n\nclass Solution {\n    public int stoneGameVII(int[] stones) {\n  
Time Complexity - O(N^2)\nSpcae Complexity - O(N^2)\nRuntime - 37ms - Faster than 90.16%\n.\n```\nclass Solution {\n    public int stoneGameVII(int[] stones) {\n        int[][] dp = new int[stones.length][stones.length];\n        int[] pre = new int[stones.length];\n        pre[0] = stones[0];\n        for(int i = 1; i < pre.length; i++)\n            pre[i] = pre[i - 1] + stones[i];\n        for(int g = 0; g < dp.length; g++){\n            for(int i = 0, j = g; j < dp.length; i++, j++){\n                if(g == 0)\n                    dp[i][j] = 0;\n                else if(g == 1)    \n                    dp[i][j] = Math.max(stones[i], stones[j]);\n                else\n                    dp[i][j] = Math.max((pre[j] - pre[i] - dp[i + 1][j]), (pre[j-1] - (i == 0 ? 0 : pre[i-1]) - dp[i][j - 1]));\n            }\n        }\n        return dp[0][stones.length - 1];\n    }\n}\n```
['Dynamic Programming', 'Java']