Recurring DP Solution with memoization
\nclass Solution {\npublic:\n    \n    int dp[1001][1001];\n    \n    int recur(vector<int>& stones, int l, int r, int sum)\n    {\n        \n        if(l==r) r
```\nclass Solution {\npublic:\n    \n    int dp[1001][1001];\n    \n    int recur(vector<int>& stones, int l, int r, int sum)\n    {\n        \n        if(l==r) return 0;\n        \n        if(dp[l][r]!=-1) return dp[l][r];\n        \n        dp[l][r] = max(abs(sum-stones[l] - recur(stones,l+1,r,sum-stones[l])),\n                       abs(sum-stones[r] - recur(stones,l,r-1,sum-stones[r])));\n        \n        return dp[l][r];\n        \n    }\n    \n    int stoneGameVII(vector<int>& stones) {\n        \n        memset(dp,-1,sizeof(dp));\n        \n        int sum=0;\n        \n        for(auto xx:stones) sum+=xx;\n        \n        return recur(stones,0,stones.size()-1,sum);\n        \n    }\n};\n```
[]