MCM || Little Variation || Aditya Verma Style || C++
class Solution {\npublic:\n    \n     int dp[502][502];\n    \n    int solve_memo(vector&arr,int i,int j)\n    {\n        // base condition \n        if(i>=j) r
class Solution {\npublic:\n    \n     int dp[502][502];\n    \n    int solve_memo(vector<int>&arr,int i,int j)\n    {\n        // base condition \n        if(i>=j) return 0;\n        \n        \n        if(dp[i][j]!=-1) return dp[i][j];\n        \n        int ans =INT_MIN;\n        for(int k=i;k<j;k++)\n        {\n            int tempAns = solve_memo(arr,i,k)+solve_memo(arr,k+1,j) + (arr[i-1]*arr[k]*arr[j]);\n            \n            ans=max(ans,tempAns);\n        }\n        return dp[i][j]=ans;\n        \n    }\n    \n    int maxCoins(vector<int>& nums) {\n        nums.insert(nums.begin(), 1);\n        nums.insert(nums.end(), 1);\n        memset(dp,-1,sizeof(dp));\n        return solve_memo(nums,1,nums.size()-1);\n    }\n};
[]