1039. Minimum Score Triangulation of Polygon
// This is nothing but matrix chain multiplication .\n\n\nclass Solution {\n    public int minScoreTriangulation(int[] values) {\n        int N = values.length;
**// This is nothing but matrix chain multiplication .**\n\n```\nclass Solution {\n    public int minScoreTriangulation(int[] values) {\n        int N = values.length;\n        int dp [][] = new int [N][N];\n        for(int i = 0 ; i < N ; i++){\n            for(int j = 0 ; j < N ; j++){\n                dp[i][j]= -1;\n            }\n        }\n       return helper(values , 1 , N-1, dp);\n    }\n    static int helper(int arr[], int i , int j , int dp [][] ){\n        if(i >= j ){\n            return 0;\n        }\n        \n        if(dp[i][j] != -1 ){\n            return dp[i][j];\n        }\n         int min = Integer.MAX_VALUE;\n        for(int k = i ; k <= j-1 ; k++){\n            int temp = helper(arr , i , k, dp)+helper(arr , k+1 , j, dp)+ (arr[i-1]*arr[k]*arr[j]);\n            min = Math.min(min , temp);\n        }\n        return dp[i][j]=min;\n    }\n}\n```
['Dynamic Programming', 'Memoization', 'Java']