Best C++ Solution | 0ms, beats 100% | DP
Code\ncpp []\nclass Solution {\npublic:\n    int solve(vector<int>& v, int i, int j, vector<vector<int>>& dp) {\n        if(i+1 == j) return 0;\n\n        if(dp
# Code\n```cpp []\nclass Solution {\npublic:\n    int solve(vector<int>& v, int i, int j, vector<vector<int>>& dp) {\n        if(i+1 == j) return 0;\n\n        if(dp[i][j] != -1) return dp[i][j];\n\n        int ans = INT_MAX;\n        for(int k=i+1; k<j; k++) {\n            ans = min(ans, v[i]*v[j]*v[k] + solve(v, k, j, dp) + solve(v, i, k, dp));\n        }\n        dp[i][j] = ans;\n        return dp[i][j];\n    }\n\n    int minScoreTriangulation(vector<int>& values) {\n        int n = values.size();\n        vector<vector<int>> dp(n, vector<int>(n, -1));\n        int ans = solve(values, 0, n-1, dp);\n        return ans;\n    }\n};\n```
['C++']