dynamic programming use a 2D matrix to check Palindrome and 1D array to get Min Cut