###### Middle-题目78：131. 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”]
]

public class Solution {
public List<List<String>> partition(String s) {
List<List<String>> list = new ArrayList<List<String>>();
backtrack(list,new ArrayList<>(),s);
return list;
}
private void backtrack(List<List<String>> list, List<String> sublist, String s) {
if(s.length() == 0) {
}
else {
for(int i = 1; i<=s.length();i++) {
if(isPalindrome(s.substring(0, i))) {
backtrack(list, sublist, s.substring(i));
sublist.remove(sublist.size()-1);
}
}
}
}
public boolean isPalindrome(String s) {
if(s==null||s.length()==0)
return true;

for(int i = 0,j = s.length()-1;i<j;i++,j--) {
if(s.charAt(i)!=s.charAt(j))
return false;
}
return true;
}
}

8ms,beats 31.90%,众数8ms,29.29%

#### 131. Palindrome Partitioning | Java最短代码实现

2016-03-24 00:41:15

#### LeetCode（131）Palindrome Partitioning

2015-12-28 13:42:37

#### [leetcode-131]Palindrome Partitioning(java)

2015-08-13 09:55:45

#### 1044 - Palindrome Partitioning(记忆化DP)

2016-03-09 23:22:32

#### LeetCode131:Palindrome Partitioning

2015-07-07 17:51:57

#### LeetCode 131. Palindrome Partitioning（回文分区）

2016-05-27 00:25:24

#### LeetCode 131 Palindrome Partitioning

2014-10-27 15:07:00

#### [LeetCode]131.Palindrome Partitioning

2015-03-02 21:07:34

#### leetcode131—Palindrome Partitioning

2016-07-29 10:56:35

#### leetcode之 Palindrome Partitioning I&II

2013-11-20 21:06:00

## 不良信息举报

Middle-题目78：131. Palindrome Partitioning