Merge branch 'master' of github.com:youngyangyang04/leetcode-master
This commit is contained in:
@@ -490,15 +490,15 @@ var partition = function(s) {
|
||||
const res = [], path = [], len = s.length;
|
||||
backtracking(0);
|
||||
return res;
|
||||
function backtracking(i) {
|
||||
if(i >= len) {
|
||||
function backtracking(startIndex) {
|
||||
if(startIndex >= len) {
|
||||
res.push(Array.from(path));
|
||||
return;
|
||||
}
|
||||
for(let j = i; j < len; j++) {
|
||||
if(!isPalindrome(s, i, j)) continue;
|
||||
path.push(s.slice(i, j + 1));
|
||||
backtracking(j + 1);
|
||||
for(let i = startIndex; i < len; i++) {
|
||||
if(!isPalindrome(s, startIndex, i)) continue;
|
||||
path.push(s.slice(startIndex, i + 1));
|
||||
backtracking(i + 1);
|
||||
path.pop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user