C++ || Clean Code || All approaches
\n//Recursive code:\nclass Solution {\npublic:\n    \n    int solve(int i, int j, vector<int>& nums){\n        if(i>j)\n            return 0;\n        int maxi 
```\n//Recursive code:\nclass Solution {\npublic:\n    \n    int solve(int i, int j, vector<int>& nums){\n        if(i>j)\n            return 0;\n        int maxi = INT_MIN;\n        for(int k = i; k<=j; k++){\n            int cost = nums[i-1]*nums[k]*nums[j+1] + solve(i, k-1, nums) + solve(k+1, j, nums);\n            maxi = max(maxi, cost);\n        }\n        \n        return maxi;\n    }\n    \n    int maxCoins(vector<int>& nums) {\n        int n = nums.size();\n        nums.push_back(1);\n        nums.insert(nums.begin(), 1);\n        \n        return solve(1, n, nums);\n    }\n};\n\n\n//Memoization [Accepted]:\nclass Solution {\npublic:\n    \n    int solve(int i, int j, vector<int>& nums, vector<vector<int>>& memo){\n        if(i>j)\n            return 0;\n        if(memo[i][j]!=-1){\n            return memo[i][j];\n        }\n        int maxi = INT_MIN;\n        for(int k = i; k<=j; k++){\n            int cost = nums[i-1]*nums[k]*nums[j+1] + solve(i, k-1, nums, memo) + solve(k+1, j, nums, memo);\n            maxi = max(maxi, cost);\n        }\n        \n        return memo[i][j] = maxi;\n    }\n    \n    int maxCoins(vector<int>& nums) {\n        int n = nums.size();\n        nums.push_back(1);\n        nums.insert(nums.begin(), 1);\n        vector<vector<int>> memo(n+1, vector<int> (n+1, -1));\n        return solve(1, n, nums, memo);\n    }\n};\n\n\n//Tabulation DP[Accepted]:\nclass Solution {\npublic:\n   \n    int maxCoins(vector<int>& nums) {\n        int n = nums.size();\n        nums.push_back(1);\n        nums.insert(nums.begin(), 1);\n        vector<vector<int>> dp(n+2, vector<int> (n+2, 0));\n        \n        for(int i= n; i>=1; i--){\n            for(int j = 1; j<=n; j++){\n                if(i>j) continue;\n                int maxi = INT_MIN;\n                for(int k = i; k<=j; k++){\n                    int cost = nums[i-1]*nums[k]*nums[j+1] + dp[i][k-1] + dp[k+1][j];\n                    maxi = max(maxi, cost);\n                }\n\n                dp[i][j] = maxi;\n            }\n                \n        }\n        \n        return dp[1][n];\n    }\n};\n\n```
['Dynamic Programming', 'Recursion', 'C']