C++, top-down recursive
\n\nclass Solution {\npublic:\n    int minScoreTriangulation(vector<int>& values)\n    {\n        int n=values.size();\n        \n        vector<vector<int>> ca
```\n\nclass Solution {\npublic:\n    int minScoreTriangulation(vector<int>& values)\n    {\n        int n=values.size();\n        \n        vector<vector<int>> cache(n,vector<int>(n,-1));\n        return calculate(values, 0, n - 1, cache);\n    }\n\n    int calculate(vector<int>& values, int from, int to,vector<vector<int>>& cache)\n    {\n        if (to - from < 2) return 0;\n        if (to - from == 2) return values[from] * values[from + 1] * values[from + 2];\n        \n        if(cache[from][to]>=0) return cache[from][to];\n\n        int v1 = values[from];\n        int v2 = values[to];\n\n        int minProd = INT_MAX;\n\n        for (int k = from + 1; k < to; ++k)\n        {\n            int curProd = v1 * v2 * values[k];\n            \n            int p1 = calculate(values, from, k, cache);\n            int p2 = calculate(values, k, to, cache);\n\n            int prod =  curProd + p1 + p2;\n            \n            minProd = min(minProd, prod);\n        }\n        \n        cache[from][to]=minProd;\n        return minProd;\n    }\n};\n```
[]