diff --git a/problems/0131.分割回文串.md b/problems/0131.分割回文串.md index 0081223c..070b5182 100644 --- a/problems/0131.分割回文串.md +++ b/problems/0131.分割回文串.md @@ -488,15 +488,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(); } } diff --git a/problems/0491.递增子序列.md b/problems/0491.递增子序列.md index c0196973..c764a1c3 100644 --- a/problems/0491.递增子序列.md +++ b/problems/0491.递增子序列.md @@ -399,7 +399,7 @@ var findSubsequences = function(nums) { ``` -## TypeScript +### TypeScript ```typescript function findSubsequences(nums: number[]): number[][] { @@ -545,7 +545,7 @@ int** findSubsequences(int* nums, int numsSize, int* returnSize, int** returnCol } ``` -## Swift +### Swift ```swift func findSubsequences(_ nums: [Int]) -> [[Int]] { @@ -576,7 +576,7 @@ func findSubsequences(_ nums: [Int]) -> [[Int]] { ``` -## Scala +### Scala ```scala object Solution {