C++ || Memoization || Easy to Understand
```\nclass Solution {\npublic:\n    int solve(vector &a,int i,int j,int sum,bool isAliceTurn,vector> &dp)\n    {\n        if(i>j)\n        {\n            // if 
```\nclass Solution {\npublic:\n    int solve(vector<int> &a,int i,int j,int sum,bool isAliceTurn,vector<vector<int>> &dp)\n    {\n        if(i>j)\n        {\n            // if there is no element in array then Alice and Bob\'s scores are 0\n            // So the difference is also 0\n            return 0;\n        }\n        if(dp[i][j]!=-1)\n        {\n            //if ans is previously computed then return \n            return dp[i][j];\n        }\n        if(isAliceTurn)\n        {\n           \n            //the recursive function returns the score diff and Alice wants to maximise it so he will add his score in the diff\n            \n             \n            int op1=solve(a,i+1,j,sum-a[i],!isAliceTurn,dp)+(sum-a[i]); //choose from start\n            int op2=solve(a,i,j-1,sum-a[j],!isAliceTurn,dp)+(sum-a[j]); //choose from end\n            return dp[i][j]=max(op1,op2); //return the max diff as Alice wants\n        }\n        else //it\'s Bob turn\n        {\n             //the recursive function returns the score diff and Bob wants to maximise it so he will subtract his score from the diff\n            \n            int op1=solve(a,i+1,j,sum-a[i],!isAliceTurn,dp)-(sum-a[i]); //choose from start\n            int op2=solve(a,i,j-1,sum-a[j],!isAliceTurn,dp)-(sum-a[j]); //choose from end\n            return dp[i][j]=min(op1,op2); //return the min diff as Bob wants\n        }\n    }\n    int stoneGameVII(vector<int>& a) {\n        int n=a.size();\n        int sum=0;\n        for(auto i:a)\n        {\n            sum+=i;\n        }\n        vector<vector<int>> dp(1001,vector<int>(1001,-1));\n        return solve(a,0,n-1,sum,true,dp);\n        \n    }\n};
[]