Simple c++ solution using Memoization
\nclass Solution {\npublic:\n    int t[1001][1001];\n    \n    int solve(vector<int> &stones, int left, int right, int sum)\n    {\n        if(left>=right)\n   
```\nclass Solution {\npublic:\n    int t[1001][1001];\n    \n    int solve(vector<int> &stones, int left, int right, int sum)\n    {\n        if(left>=right)\n            return 0;\n        \n        if(t[left][right]!=-1)\n            return t[left][right];\n        \n        if(left-right==1)\n            return t[left][right]=max(stones[left],stones[right]);\n        \n        int first=sum-stones[left]-solve(stones, left+1, right, sum-stones[left]);\n        int second=sum-stones[right]-solve(stones, left, right-1, sum-stones[right]);\n        \n        return t[left][right]=max(first,second);\n        \n    }\n    \n    \n    \n    int stoneGameVII(vector<int>& stones) {\n        int n=stones.size();\n        int i,j,sum=0;\n        for(i=0;i<n;i++)\n        {\n            sum+=stones[i];\n        }\n        \n        for(i=0;i<=n;i++)\n        {\n            for(j=0;j<=n;j++)\n                t[i][j]=-1;\n        }\n        \n        return solve(stones,0,n-1,sum);\n        \n        \n        \n    }\n};\n```
[]