Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[pull] master from youngyangyang04:master #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
pull merged 6 commits into AlgorithmAndLeetCode:master from youngyangyang04:master
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions problems/0072.编辑距离.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ function minDistance(word1: string, word2: string): number {

C:


```c
int min(int num1, int num2, int num3) {
return num1 > num2 ? (num2 > num3 ? num3 : num2) : (num1 > num3 ? num3 : num1);
Expand All @@ -376,7 +377,7 @@ int minDistance(char * word1, char * word2){
for (int i = 1; i <= strlen(word2); i++) dp[0][i] = i;

for (int i = 1; i <= strlen(word1); i++) {
for (int j = 1; j <=strlen(word2); j++) {
for (int j = 1; j <=strlen(word2); j++) {
if (word1[i-1] == word2[j-1]) {
dp[i][j] = dp[i-1][j-1];
}
Expand All @@ -389,7 +390,5 @@ int minDistance(char * word1, char * word2){
}
```



-----------------------
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>
33 changes: 33 additions & 0 deletions problems/0090.子集II.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,39 @@ function subsetsWithDup(nums: number[]): number[][] {
};
```

set去重版本:
```typescript
// 使用set去重版本
function subsetsWithDup(nums: number[]): number[][] {
const result: number[][] = [];
const path: number[] = [];
// 去重之前先排序
nums.sort((a, b) => a - b);
function backTracking(startIndex: number) {
// 收集结果
result.push([...path])
// 此处不返回也可以因为,每次递归都会使startIndex + 1,当这个数大到nums.length的时候就不会进入递归了。
if (startIndex === nums.length) {
return
}
// 定义每一个树层的set集合
const set: Set<number> = new Set()
for (let i = startIndex; i < nums.length; i++) {
// 去重
if (set.has(nums[i])) {
continue
}
set.add(nums[i])
path.push(nums[i])
backTracking(i + 1)
// 回溯
path.pop()
}
}
backTracking(0)
return result
};
```
### Rust

```Rust
Expand Down

AltStyle によって変換されたページ (->オリジナル) /