C++ Explained | MCM variation
Because we need to check for every possible combination of sides, therefore, we can approach this question by MCM. \n\n\nclass Solution {\npublic:\n    \n    in
Because we need to check for every possible combination of sides, therefore, we can approach this question by MCM. \n\n```\nclass Solution {\npublic:\n    \n    int dp[1005][1005];\n    \n    int MSTP(vector <int> &arr, int i, int j){\n        if(i >= j)\n            return 0;\n        \n        if(dp[i][j] != -1)\n            return dp[i][j];\n    \n        int ans = INT_MAX;\n        for(int k = i; k<j; k++){\n\n            int left = MSTP(arr, i, k);\n            int right = MSTP(arr, k+1, j);\n\t\t\t\t\t\t\t\t\t// cost of joining the two parts \n            int count = left+right + arr[i-1]*arr[k]*arr[j];\n            \n            ans = min(ans, count);\n        }\n        return dp[i][j] = ans;\n    }\n    \n    int minScoreTriangulation(vector<int>& values) {\n        int n = values.size();\n        \n        memset(dp, -1, sizeof(dp));\n        \n        return MSTP(values, 1, n-1);\n    }\n};\n```
['Dynamic Programming', 'C']