public int minCut(String s) {
        if (s == null || s.length() == 0) {
            return 0;
        }
        boolean[][] matrix = createParlindromMatrix(s);
        int[] result = new int[s.length() + 1];
        for (int i = 1; i <= s.length(); i++) {
            int min = Integer.MAX_VALUE;
            for (int j = i; j >= 1; j++) {
                if (matrix[j - 1][i] && result[j - 1] != Integer.MAX_VALUE) {
                    min = Math.min(min, result[j - 1] + 1);
                }
            }
            result[i] = min;
        }
        return result[s.length()];
    }