C++ Aditya Verma solution
If you are thinking why the movement is from i to k-1 and k+1 to j it is because we are consuming an element of an array rather than adding a bracket or a paran
If you are thinking why the movement is from i to k-1 and k+1 to j it is because we are consuming an element of an array rather than adding a bracket or a paranthesis\n\n\n```\nclass Solution {\npublic:\n    \n    int dp[502][502];\n    int help(vector<int>&nums,int i,int j)\n    {\n        if(i>j)\n            return 0;\n            if(dp[i][j]!=-1)\n                return dp[i][j];\n        int maxi=INT_MIN;\n        \n        for(int k=i;k<=j;k++)\n        {\n            int temp=help(nums,i,k-1)+help(nums,k+1,j);\n            int l=1,r=1;\n            if(i-1>=0)\n                l=nums[i-1];\n            if(j+1<nums.size())\n                r=nums[j+1];\n            temp+=l*r*nums[k];\n            maxi=max(maxi,temp);\n        }\n        return dp[i][j]=maxi;\n        \n    }\n    int maxCoins(vector<int>& nums) {\n        memset(dp,-1,sizeof dp);\n        int n=nums.size();\n        return help(nums,0,n-1);\n        \n    }\n};\n```
[]