Java Matrix chain multiplication memo.
The arr[] is created as in note section is given at index -1 and n =1\nso clone the given arr and add padding.\n\nAs in mcm is given to minimize we can vary it 
The arr[] is created as in note section is given at index -1 and n =1\nso clone the given arr and add padding.\n\nAs in mcm is given to minimize we can vary it by maximize it.\n```\nclass Solution {\n    int dp[][]=new int[501][501];\n    public int maxCoins(int[] nums) {\n       \n        int arr[]=new int[nums.length+2];\n        int n=1;\n        for(int ii[]:dp)\n        {\n            Arrays.fill(ii,-1);\n        }\n        for(int x:nums)\n            arr[n++]=x;\n            arr[0]=arr[n++]=1;\n        return solve(arr,1,n-1);\n    }\n    public int solve(int arr[],int i,int j)\n    {\n        if(i>=j)\n            return 0;\n        if(dp[i][j]!=-1)\n            return dp[i][j];\n        int max=Integer.MIN_VALUE;\n        for(int k=i;k<=j-1;k++)\n        {\n            int temp=solve(arr,i,k)+solve(arr,k+1,j)+arr[i-1]*arr[k]*arr[j];\n            max=Math.max(max,temp);\n        }\n        return dp[i][j]=max;\n    }\n}\n```
['Dynamic Programming', 'Memoization', 'Java']