leetcode JAVA Palindrome Partitioning 3.45 难度系数3

2014-11-24 02:45:32 · 作者: · 浏览: 0

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"]
  ]
public class Solution {
    public ArrayList
  
   > partition(String s) {
		ArrayList
   
    > results = new ArrayList<>(); ArrayList
    
      result = new ArrayList<>(); dfs(s,0,result,results); return results; } private void dfs(String s, int step, ArrayList
     
       result, ArrayList
      
       > results) { if(step==s.length()){ results.add(new ArrayList
       
        (result)); } for(int i=step;i