From 0131465339d570fb8c47ddea3eb8f9a7d6cbf577 Mon Sep 17 00:00:00 2001 From: 5Reason Date: Tue, 6 Dec 2022 12:03:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20131.=E5=88=86=E5=89=B2?= =?UTF-8?q?=E5=9B=9E=E6=96=87=20=E4=B8=B2=20js=E4=BB=A3=E7=A0=81=E7=9A=84?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E5=90=8D,=E5=92=8C=E6=95=99=E7=A8=8B?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4=E9=81=BF=E5=85=8D=E6=B7=B7?= =?UTF-8?q?=E6=B7=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0131.分割回文串.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/problems/0131.分割回文串.md b/problems/0131.分割回文串.md index 3a3c2d73..8e180ec8 100644 --- a/problems/0131.分割回文串.md +++ b/problems/0131.分割回文串.md @@ -494,15 +494,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(); } } From 50aba633cc9be0b85a5786142020875a77cc4bbe Mon Sep 17 00:00:00 2001 From: 5Reason Date: Fri, 9 Dec 2022 14:54:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20491.=E9=80=92=E5=A2=9E?= =?UTF-8?q?=E5=AD=90=E5=BA=8F=E5=88=97=20=E4=BF=AE=E6=AD=A3=E5=AD=90?= =?UTF-8?q?=E6=A0=87=E9=A2=98md=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0491.递增子序列.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/problems/0491.递增子序列.md b/problems/0491.递增子序列.md index e33a049d..c30d23f7 100644 --- a/problems/0491.递增子序列.md +++ b/problems/0491.递增子序列.md @@ -396,7 +396,7 @@ var findSubsequences = function(nums) { ``` -## TypeScript +### TypeScript ```typescript function findSubsequences(nums: number[]): number[][] { @@ -542,7 +542,7 @@ int** findSubsequences(int* nums, int numsSize, int* returnSize, int** returnCol } ``` -## Swift +### Swift ```swift func findSubsequences(_ nums: [Int]) -> [[Int]] { @@ -573,7 +573,7 @@ func findSubsequences(_ nums: [Int]) -> [[Int]] { ``` -## Scala +### Scala ```scala object Solution {