[recommend for beginners]clean C++ implementation with detailed explanation
class Solution {\n    public:\n        int maxCoins(vector<int>& nums) {\n            vector<int> _nums(nums);\n            _nums.insert(_nums.begin(), 1);\n   
    class Solution {\n    public:\n        int maxCoins(vector<int>& nums) {\n            vector<int> _nums(nums);\n            _nums.insert(_nums.begin(), 1);\n            _nums.push_back(1);\n            int n=_nums.size();\n            vector<vector<int>> matrix(n, vector<int>(n, 0));\n            //return 0;\n            return help(_nums, matrix, 0, n-1);\n        }\n        /*** (start, end)  ***/\n        int help(vector<int>& nums, vector<vector<int>>& matrix, int low, int high){\n            if(low+1==high)  return 0;\n            if(matrix[low][high]>0)  return matrix[low][high];\n            int result=0;\n            for(int i=low+1; i<high; i++){\n                result=max(result, nums[low]*nums[i]*nums[high],\n                                   +help(nums, matrix, low, i)\n                                   +help(nums, matrix, i, high));\n            }\n            matrix[low][high]=result;\n            return result;\n        }\n    };
[]