[C++] Dp.  I think a lot of time to understand how to  use dp.
\n\nclass Solution {\npublic:\n    int maxCoins(vector<int>& nums) {\n        int len = nums.size();\n        nums.insert(nums.begin(), 1);\n        nums.push_b
![image](https://assets.leetcode.com/users/xdh1cat/image_1592371264.png)\n```\nclass Solution {\npublic:\n    int maxCoins(vector<int>& nums) {\n        int len = nums.size();\n        nums.insert(nums.begin(), 1);\n        nums.push_back(1);\n         \n        vector<vector<int>> dp(len+2, vector<int>(len+2,0));\n        for (int iv = 0; iv<len;iv++ ) {   \n            for (int left = 1; left <=len-iv;left++) {\n                int right = left + iv;\n                for (int k = left; k<=right; k++) {\n                    dp[left][right] = max(dp[left][right], nums[left-1]*nums[k]*nums[right+1] + dp[left][k-1] +dp[k+1][right]);\n                }\n            }    \n        }\n        return dp[1][len];\n    }\n};\n```\n
[]