本文共 713 字,大约阅读时间需要 2 分钟。
Palindrome Partitioning
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"] ]
解题分析:
Java代码:
public class Solution { List
> resultLst; ArrayList currLst; public List
> partition(String s) { resultLst = new ArrayList
>(); currLst = new ArrayList (); backTrack(s,0); return resultLst; } public void backTrack(String s, int l){ if(currLst.size()>0 //the initial str could be palindrome && l>=s.length()){ List r = (ArrayList ) currLst.clone(); resultLst.add(r); } for(int i=l;i
转载地址:http://kpuni.baihongyu.com/