Java Top Down DP Solution
\nclass Solution {\n    int[][] dp;\n    public int stoneGameVII(int[] stones) {\n        int len = stones.length;\n        dp = new int[len][len];\n        \n 
```\nclass Solution {\n    int[][] dp;\n    public int stoneGameVII(int[] stones) {\n        int len = stones.length;\n        dp = new int[len][len];\n        \n        int sum = 0;\n        for(int n: stones)\n            sum += n;\n        \n        for(int[] row: dp)\n            Arrays.fill(row, -1);\n        \n        return helper(stones, 0, len - 1, sum, 0);\n    }\n    \n    private int helper(int[] piles, int start, int end, int sum, int player)\n    {\n        if(start == end) return 0;\n        if(dp[start][end] != -1) return dp[start][end];\n        // if current player is Alice, we will try to Maximize Alice\'s Score \n        if(player == 0)\n        { \n            int choice1 = sum - piles[start] + helper(piles, start + 1, end, sum - piles[start], 1);\n            int choice2 = sum - piles[end] + helper(piles, start, end - 1, sum - piles[end], 1);\n            dp[start][end] = Math.max(choice1, choice2);\n        }\n\t\t// else we will Minimize Bob\'s Score from the remaining Score\n        else\n        {\n            int choice1 = helper(piles, start + 1, end, sum - piles[start], 0) - (sum - piles[start]);\n            int choice2 = helper(piles, start, end - 1, sum - piles[end], 0) - (sum - piles[end]);\n            dp[start][end] = Math.min(choice1, choice2);\n        }\n        \n        return dp[start][end];\n    }\n}\n```
['Dynamic Programming', 'Memoization', 'Java']