Stone Game VII | Dynamic Programming C++ | Beats 99.68% of runtime
Runtime: 84 ms\nMemory Usage: 14 MB\n\nclass Solution {\npublic:\n    int dp[1002][1002] ={0};\n    \n    \n    int stoneGameVII(vector<int>& stones) {\n       
Runtime: 84 ms\nMemory Usage: 14 MB\n```\nclass Solution {\npublic:\n    int dp[1002][1002] ={0};\n    \n    \n    int stoneGameVII(vector<int>& stones) {\n        int n = stones.size();\n        int total = 0;\n        for (int i = n-2; i >=0; i--){\n            total = stones[i]+stones[i+1];\n            dp[i][i+1] = max(stones[i], stones[i+1]);\n            for (int j = i+2; j < n; j++){\n                total += stones[j];\n                dp[i][j] = max(total-stones[i]-dp[i+1][j], \n                               total-stones[j]-dp[i][j-1]);\n            }\n        }\n        return dp[0][n-1];\n    }\n};\n```
['C', 'C++']