mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-07 07:35:35 +08:00
Merge pull request #1803 from 5Reasons/master
更新 131.分割回文 串 js代码的变量名,和教程保持一致避免混淆
This commit is contained in:
@ -488,15 +488,15 @@ var partition = function(s) {
|
|||||||
const res = [], path = [], len = s.length;
|
const res = [], path = [], len = s.length;
|
||||||
backtracking(0);
|
backtracking(0);
|
||||||
return res;
|
return res;
|
||||||
function backtracking(i) {
|
function backtracking(startIndex) {
|
||||||
if(i >= len) {
|
if(startIndex >= len) {
|
||||||
res.push(Array.from(path));
|
res.push(Array.from(path));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(let j = i; j < len; j++) {
|
for(let i = startIndex; i < len; i++) {
|
||||||
if(!isPalindrome(s, i, j)) continue;
|
if(!isPalindrome(s, startIndex, i)) continue;
|
||||||
path.push(s.slice(i, j + 1));
|
path.push(s.slice(startIndex, i + 1));
|
||||||
backtracking(j + 1);
|
backtracking(i + 1);
|
||||||
path.pop();
|
path.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -399,7 +399,7 @@ var findSubsequences = function(nums) {
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## TypeScript
|
### TypeScript
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
function findSubsequences(nums: number[]): number[][] {
|
function findSubsequences(nums: number[]): number[][] {
|
||||||
@ -545,7 +545,7 @@ int** findSubsequences(int* nums, int numsSize, int* returnSize, int** returnCol
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Swift
|
### Swift
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
func findSubsequences(_ nums: [Int]) -> [[Int]] {
|
func findSubsequences(_ nums: [Int]) -> [[Int]] {
|
||||||
@ -576,7 +576,7 @@ func findSubsequences(_ nums: [Int]) -> [[Int]] {
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Scala
|
### Scala
|
||||||
|
|
||||||
```scala
|
```scala
|
||||||
object Solution {
|
object Solution {
|
||||||
|
Reference in New Issue
Block a user