Skip to content

Commit ba27574

Browse files
authored
Merge branch 'doocs:main' into main
2 parents f961728 + 11b9cba commit ba27574

File tree

72 files changed

+4548
-69
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+4548
-69
lines changed

solution/0000-0099/0014.Longest Common Prefix/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ difficulty: 简单
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0000-0099/0014.Longest%20Common%20Prefix/README.md
55
tags:
66
- 字典树
7+
- 数组
78
- 字符串
89
---
910

solution/0000-0099/0014.Longest Common Prefix/README_EN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ difficulty: Easy
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0000-0099/0014.Longest%20Common%20Prefix/README_EN.md
55
tags:
66
- Trie
7+
- Array
78
- String
89
---
910

solution/0500-0599/0594.Longest Harmonious Subsequence/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,28 @@ function findLHS(nums: number[]): number {
174174
}
175175
```
176176

177+
#### Rust
178+
179+
```rust
180+
use std::collections::HashMap;
181+
182+
impl Solution {
183+
pub fn find_lhs(nums: Vec<i32>) -> i32 {
184+
let mut cnt = HashMap::new();
185+
for &x in &nums {
186+
*cnt.entry(x).or_insert(0) += 1;
187+
}
188+
let mut ans = 0;
189+
for (&x, &c) in &cnt {
190+
if let Some(&y) = cnt.get(&(x + 1)) {
191+
ans = ans.max(c + y);
192+
}
193+
}
194+
ans
195+
}
196+
}
197+
```
198+
177199
<!-- tabs:end -->
178200

179201
<!-- solution:end -->

solution/0500-0599/0594.Longest Harmonious Subsequence/README_EN.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,28 @@ function findLHS(nums: number[]): number {
170170
}
171171
```
172172

173+
#### Rust
174+
175+
```rust
176+
use std::collections::HashMap;
177+
178+
impl Solution {
179+
pub fn find_lhs(nums: Vec<i32>) -> i32 {
180+
let mut cnt = HashMap::new();
181+
for &x in &nums {
182+
*cnt.entry(x).or_insert(0) += 1;
183+
}
184+
let mut ans = 0;
185+
for (&x, &c) in &cnt {
186+
if let Some(&y) = cnt.get(&(x + 1)) {
187+
ans = ans.max(c + y);
188+
}
189+
}
190+
ans
191+
}
192+
}
193+
```
194+
173195
<!-- tabs:end -->
174196

175197
<!-- solution:end -->
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use std::collections::HashMap;
2+
3+
impl Solution {
4+
pub fn find_lhs(nums: Vec<i32>) -> i32 {
5+
let mut cnt = HashMap::new();
6+
for &x in &nums {
7+
*cnt.entry(x).or_insert(0) += 1;
8+
}
9+
let mut ans = 0;
10+
for (&x, &c) in &cnt {
11+
if let Some(&y) = cnt.get(&(x + 1)) {
12+
ans = ans.max(c + y);
13+
}
14+
}
15+
ans
16+
}
17+
}

solution/0900-0999/0912.Sort an Array/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ tags:
3737
<pre>
3838
<strong>输入:</strong>nums = [5,2,3,1]
3939
<strong>输出:</strong>[1,2,3,5]
40+
<strong>解释:</strong>数组排序后,某些数字的位置没有改变(例如,2 和 3),而其他数字的位置发生了改变(例如,1 和 5)。
4041
</pre>
4142

4243
<p><strong>示例 2:</strong></p>
4344

4445
<pre>
4546
<strong>输入:</strong>nums = [5,1,1,2,0,0]
4647
<strong>输出:</strong>[0,0,1,1,2,5]
48+
<strong>解释:</strong>请注意,nums 的值不一定唯一。
4749
</pre>
4850

4951
<p>&nbsp;</p>

solution/0900-0999/0912.Sort an Array/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ tags:
4141
<pre>
4242
<strong>Input:</strong> nums = [5,1,1,2,0,0]
4343
<strong>Output:</strong> [0,0,1,1,2,5]
44-
<strong>Explanation:</strong> Note that the values of nums are not necessairly unique.
44+
<strong>Explanation:</strong> Note that the values of nums are not necessarily unique.
4545
</pre>
4646

4747
<p>&nbsp;</p>

solution/0900-0999/0923.3Sum With Multiplicity/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tags:
1212

1313
<!-- problem:start -->
1414

15-
# [923. 三数之和的多种可能](https://leetcode.cn/problems/3sum-with-multiplicity)
15+
# [923. 多重三数之和](https://leetcode.cn/problems/3sum-with-multiplicity)
1616

1717
[English Version](/solution/0900-0999/0923.3Sum%20With%20Multiplicity/README_EN.md)
1818

solution/1100-1199/1152.Analyze User Website Visit Pattern/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source: 第 6 场双周赛 Q3
77
tags:
88
- 数组
99
- 哈希表
10+
- 字符串
1011
- 排序
1112
---
1213

solution/1100-1199/1152.Analyze User Website Visit Pattern/README_EN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source: Biweekly Contest 6 Q3
77
tags:
88
- Array
99
- Hash Table
10+
- String
1011
- Sorting
1112
---
1213

0 commit comments

Comments
 (0)