C++ DP solution
I got the idea from dietpepsi's post, but had a hard time to understand the usage of "nums[left] * nums[i] * nums[right]"  in his implementation. So I changed t
I got the idea from dietpepsi's post, but had a hard time to understand the usage of "nums[left] * nums[i] * nums[right]"  in his implementation. So I changed the definition of dp state a little bit, which I can understand better. In following code, dp[start][end] is defined as the maximum coins we can get by bursting balloons between "start" and "end" (exclusively, means "start" and "end" won't burst).\n\n\n    int maxCoins(vector<int>& nums) {\n        nums.insert(nums.begin(), 1);\n        nums.push_back(1);\n        int n = nums.size();\n        vector<vector<int>> dp(n, vector<int>(n, 0));\n\n        for (int len = 1; len < n - 1; len ++) {\n            for (int start = 0; start < n - 1 - len; start ++) {\n                int end = start + len + 1;\n                \n                for (int k = start + 1; k < end; k ++) {\n                    dp[start][end] = max(dp[start][end], dp[start][k] + dp[k][end] + nums[start] * nums[k] * nums[end]);\n                }\n            }\n        }\n        \n        return dp[0][n-1];\n    }
[]