131. Palindrome Partitioning

#### QUESTION:

Given a string s, partition s such that every substring of the partition is a palindrome.

Return all possible palindrome partitioning of s.

For example, given s = `"aab"`, Return

``````[
["aa","b"],
["a","a","b"]
]
``````

#### EXPLANATION:

a是一个palindrome，所以把剩下的进行判断，那就是ab

ab中的a是一个palindrome，剩下的b进行判断

b也是palindrome，所以是一个正解，添加到集合中。

aa,b也是一个正解，aab不是正解。

#### SOLUTION:

``````class Solution {
public List<List<String>> partition(String s) {
List<List<String>> result = new ArrayList<>();
List<String> subset = new ArrayList<>();
partitionHelper(s,result,subset,0);
return result;
}
public void partitionHelper(String s,List<List<String>> result,List<String> subset,int start) {
else{
for(int i = start;i<s.length();i++){
String tmp = s.substring(start,i+1);
if(isPalindrome(tmp)){
partitionHelper(s,result,subset,i+1);
subset.remove(subset.size()-1);
}
}
}
}
public static boolean isPalindrome(String s) {
if(s == null) return true;
String ns = s.toLowerCase();
char[] chars = ns.toCharArray();
ArrayList<Character> list = new ArrayList<>();
for(char c : chars){
if((c>='a'&& c<='z') || (c>='0' && c<='9') || (c>='A' && c<='Z'))
}
Object[] objects = list.toArray();
int pre = 0;int after = objects.length-1;
while (pre<after){