public ArrayList<ArrayList<String>> partitionHelper(int end) {
        ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>();
        if (end == 0) {
            result.add(new ArrayList<String>());
            return result;
        }
        for (int i = 0; i < end; i++) {
            if (isPal[i][end - 1]) {
                for (ArrayList<String> it : partitionHelper(i)) {
                    it.add(s.substring(i, end));
                    result.add(it);
                }
            }
        }
        return result;
    }