@@ -0,0 +1,909 @@
+// Given a string s, partition s such that every substring of the partition is a palindrome.%0A%0A// Return the minimum cuts needed for a palindrome partitioning of s.%0A%0A// For example, given s = %22aab%22,%0A// Return 1 since the palindrome partitioning %5B%22aa%22,%22b%22%5D could be produced using 1 cut.%0A%0Apublic class Solution %7B%0A%09public int minCut(String s) %7B%0A%09%09int len = s.length();%0A%09%09if(len == 0) return len;%0A%0A%09%09int%5B%5D cuts = new int%5Blen + 1%5D;%0A%09%09boolean%5B%5D%5B%5D m = new boolean%5Blen%5D%5Blen%5D;%0A%0A%09%09for(int i = 0; i %3C= len; i++)%7B%0A%09%09%09cuts%5Bi%5D = len - i;%0A%09%09%7D%0A%0A%09%09for(int i = len - 1; i %3E= 0; i--)%7B%0A%09%09%09for(int j = i; j %3C len; j++)%7B%0A%09%09%09%09boolean sameChar = s.charAt(i) == s.charAt(j);%0A%09%09%09%09if( (sameChar&&(j - i %3C 2) )%7C%7C (sameChar && m%5Bi + 1%5D%5Bj - 1%5D))%7B%0A%09%09%09%09%09m%5Bi%5D%5Bj%5D = true;%0A%09%09%09%09%09int rightCut = cuts%5Bj + 1%5D + 1;%0A%09%09%09%09%09int currentCut = cuts%5Bi%5D;%0A%09%09%09%09%09cuts%5Bi%5D = currentCut %3C rightCut? currentCut : rightCut;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09return cuts%5B0%5D - 1;%0A%09%7D%0A%7D

add palinrome partition ii solution