[C++] Clean and concise DP solution | O(n^3)
Please upvote if it helps!\n\nclass Solution {\npublic:\n    int func(vector<int>& a, int i, int j, vector<vector<int>>& dp)\n    {\n        if(j<=(i+1))\n     
Please upvote if it helps!\n```\nclass Solution {\npublic:\n    int func(vector<int>& a, int i, int j, vector<vector<int>>& dp)\n    {\n        if(j<=(i+1))\n            return 0;\n        if(dp[i][j]!=-1)\n            return dp[i][j];\n        \n        int ans=INT_MAX;\n        for(int k=i+1;k<j;k++)\n        {\n            int temp = (a[i]*a[j]*a[k]) + func(a,i,k,dp) + func(a,k,j,dp);\n            ans = min(ans,temp);\n        }\n        return dp[i][j] = ans;\n    }\n    \n    int minScoreTriangulation(vector<int>& a) {\n        int n=a.size();\n        vector<vector<int>> dp(n+1, vector<int>(n+1,-1));\n        int ans = func(a,0,n-1,dp);\n        return ans;\n    }\n};\n```
['Dynamic Programming', 'C', 'C++']