[C++] Easy to understand clean & concise dynamic programming one pass O(n*n)
Please upvote if it helps!\n\nclass Solution {\npublic:\n    int sum(vector<int>& a, int i, int j)\n    {\n        if(i>j)\n            return 0;\n        if(i=
Please upvote if it helps!\n```\nclass Solution {\npublic:\n    int sum(vector<int>& a, int i, int j)\n    {\n        if(i>j)\n            return 0;\n        if(i==0)\n            return a[j];\n        return a[j]-a[i-1];\n    }\n    \n    int stoneGameVII(vector<int>& stones) {\n        int n=stones.size();\n        for(int i=1;i<n;i++)\n            stones[i]+=stones[i-1];\n        \n        vector<vector<int>> dp(n+1, vector<int>(n+1,0));\n        for(int i=n-1;i>=0;i--)\n            for(int j=i+1;j<=n;j++)\n                    dp[i][j] = max(sum(stones,i+1,j-1) - dp[i+1][j], sum(stones,i,j-2) - dp[i][j-1]);\n        \n        return dp[0][n];\n    }\n};\n```
['Dynamic Programming', 'C', 'C++']