public class Solution {
public List> partition(String s) {
List> res = new ArrayList>();
List list = new ArrayList();
helper(s, 0, res, list);
return res;
}
public void helper(String s, int pos, List> res, List list){
if(pos == s.length()){
res.add(new ArrayList(list));
return;
}
for(int i = pos; i < s.length(); i++){
String first = s.substring(pos, i+1);
if(isPalindrome(first)){
list.add(first);
helper(s, i+1, res, list);
list.remove(list.size()-1);
}
}
}
public boolean isPalindrome(String str){
if(str == null) return false;
int i = 0;
int j = str.length()-1;
while(i