java memo
\nclass Solution {\n    int dp[][];\n    int help(int arr[],int start,int end,int total){\n        if(start>end)\n            return 0;\n        if(dp[start][en
```\nclass Solution {\n    int dp[][];\n    int help(int arr[],int start,int end,int total){\n        if(start>end)\n            return 0;\n        if(dp[start][end]!=-1)\n            return dp[start][end];\n        \n        \n        return dp[start][end]= Math.max(total-arr[start]-help(arr,start+1,end,total-arr[start]),total-arr[end]-help(arr,start,end-1,total-arr[end]));\n    }\n    public int stoneGameVII(int[] stones) {\n        dp=new int[stones.length][stones.length];\n        for(int i[]:dp){\n            Arrays.fill(i,-1);\n        }\n        int sum=0;\n        for(int i:stones){\n            sum+=i;\n        }\n        return help(stones,0,stones.length-1,sum);\n    }\n}\n```
['Memoization', 'Java']