Java code inspired by votrubac's solution.
This below solution is just an implementation in java of an awesome solution by votrubac here : https://leetcode.com/problems/minimum-score-triangulation-of-pol
This below solution is just an implementation in java of an awesome solution by votrubac here : https://leetcode.com/problems/minimum-score-triangulation-of-polygon/discuss/286753/C%2B%2B-with-picture\n```\n//Algorithm:\n//pick a side with i, j vertices, pick an anchor (k) to form a triangle.\n// move the anchor (k) along the remaining vertices and compute\n//a) the current triangle formed by i, j, k\n//b) score for the remaining polygons that could be 1 or 2. 1 where there are no points in between j and k or where there are no points in between i and k.\n//c) memoize the score for polygons.\n\nclass Solution {\n    private int[][] dp;\n    public int minScoreTriangulation(int[] A) {\n        dp = new int[A.length][A.length];\n        return minScoreHelper( A, 0, A.length - 1 );\n    }\n    \n    private int minScoreHelper( int[] A, int i, int j ) {\n        if ( j == i + 1 ) return 0; // meaning no triangle.\n        if ( dp[i][j] != 0 ) return dp[i][j];\n        int res = Integer.MAX_VALUE;\n        for ( int k = i + 1; k < j; k++ ) {\n            int thisTriangleScore = A[i]*A[k]*A[j];\n            int leftPolygonScore = minScoreHelper( A, i, k );\n            int rightPolygonScore = minScoreHelper( A, k, j );\n            res = Math.min( res, thisTriangleScore + leftPolygonScore + rightPolygonScore );\n        }\n        dp[i][j] = res;\n        return res;\n    }\n    \n}\n```
[]