public void partitionHelper(int end) {
        if (currentCut > minCut)
            return;

        if (end == 0) {
            minCut = currentCut;
            return;
        }

        for (int i = 0; i < end; i++) {
            if (isPal[i][end - 1]) {
                currentCut++;
                partitionHelper(i);
                currentCut--;
            }
        }
    }