Skip to content

Commit

Permalink
Merge pull request youngyangyang04#1163 from xiaofei-2020/back2
Browse files Browse the repository at this point in the history
添加(0077.组合.md):增加typescript版本
  • Loading branch information
youngyangyang04 authored Apr 4, 2022
2 parents 5c3ab04 + e1f3bdd commit 090dc8b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions problems/0077.组合.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,27 @@ const combineHelper = (n, k, startIndex) => {
}
```

## TypeScript

```typescript
function combine(n: number, k: number): number[][] {
let resArr: number[][] = [];
function backTracking(n: number, k: number, startIndex: number, tempArr: number[]): void {
if (tempArr.length === k) {
resArr.push(tempArr.slice());
return;
}
for (let i = startIndex; i <= n - k + 1 + tempArr.length; i++) {
tempArr.push(i);
backTracking(n, k, i + 1, tempArr);
tempArr.pop();
}
}
backTracking(n, k, 1, []);
return resArr;
};
```



## Go
Expand Down

0 comments on commit 090dc8b

Please sign in to comment.