dp || recursion+memoisation
```\nclass Solution {\npublic:\n    int dp[1001][1001];\n    int helper(vector& v , int i , int j , int sum){\n        if(i >= j or sum <= 0){\n            retu
```\nclass Solution {\npublic:\n    int dp[1001][1001];\n    int helper(vector<int>& v , int i , int j , int sum){\n        if(i >= j or sum <= 0){\n            return 0;\n        }\n        if(dp[i][j] != -1){\n            return dp[i][j];\n        }\n        int x = sum-v[i] - helper(v,i+1,j,sum-v[i]);\n        int y = sum-v[j] - helper(v,i,j-1,sum-v[j]);\n        return dp[i][j] = max(x,y);\n    }\n    int stoneGameVII(vector<int>& v) {\n        int n = v.size();\n        int s = 0;\n        for(auto x : v){\n            s+=x;\n        }\n        memset(dp , -1 , sizeof(dp));\n        return helper(v,0,n-1,s);\n    }\n};
[]