Skip to content

Commit 8c233d3

Browse files
authored
feat: update lc problems (doocs#3718)
1 parent 2e04c0f commit 8c233d3

File tree

12 files changed

+105
-7
lines changed

12 files changed

+105
-7
lines changed

solution/0200-0299/0219.Contains Duplicate II/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,26 @@ function containsNearbyDuplicate(nums: number[], k: number): boolean {
148148
}
149149
```
150150

151+
#### JavaScript
152+
153+
```js
154+
/**
155+
* @param {number[]} nums
156+
* @param {number} k
157+
* @return {boolean}
158+
*/
159+
var containsNearbyDuplicate = function (nums, k) {
160+
const d = new Map();
161+
for (let i = 0; i < nums.length; ++i) {
162+
if (d.has(nums[i]) && i - d.get(nums[i]) <= k) {
163+
return true;
164+
}
165+
d.set(nums[i], i);
166+
}
167+
return false;
168+
};
169+
```
170+
151171
#### C#
152172

153173
```cs

solution/0200-0299/0219.Contains Duplicate II/README_EN.md

+20
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,26 @@ function containsNearbyDuplicate(nums: number[], k: number): boolean {
147147
}
148148
```
149149

150+
#### JavaScript
151+
152+
```js
153+
/**
154+
* @param {number[]} nums
155+
* @param {number} k
156+
* @return {boolean}
157+
*/
158+
var containsNearbyDuplicate = function (nums, k) {
159+
const d = new Map();
160+
for (let i = 0; i < nums.length; ++i) {
161+
if (d.has(nums[i]) && i - d.get(nums[i]) <= k) {
162+
return true;
163+
}
164+
d.set(nums[i], i);
165+
}
166+
return false;
167+
};
168+
```
169+
150170
#### C#
151171

152172
```cs

solution/0200-0299/0219.Contains Duplicate II/Solution.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @param {number} k
44
* @return {boolean}
55
*/
6-
var containsNearbyDuplicate = function(nums, k) {
6+
var containsNearbyDuplicate = function (nums, k) {
77
const d = new Map();
88
for (let i = 0; i < nums.length; ++i) {
99
if (d.has(nums[i]) && i - d.get(nums[i]) <= k) {

solution/2500-2599/2524.Maximum Frequency Score of a Subarray/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ comments: true
33
difficulty: 困难
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/2500-2599/2524.Maximum%20Frequency%20Score%20of%20a%20Subarray/README.md
55
tags:
6+
-
67
- 数组
78
- 哈希表
89
- 数学

solution/2500-2599/2524.Maximum Frequency Score of a Subarray/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ comments: true
33
difficulty: Hard
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/2500-2599/2524.Maximum%20Frequency%20Score%20of%20a%20Subarray/README_EN.md
55
tags:
6+
- Stack
67
- Array
78
- Hash Table
89
- Math

solution/2600-2699/2685.Count the Number of Complete Components/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source: 第 345 场周赛 Q4
77
tags:
88
- 深度优先搜索
99
- 广度优先搜索
10+
- 并查集
1011
-
1112
---
1213

solution/2600-2699/2685.Count the Number of Complete Components/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source: Weekly Contest 345 Q4
77
tags:
88
- Depth-First Search
99
- Breadth-First Search
10+
- Union Find
1011
- Graph
1112
---
1213

solution/3100-3199/3163.String Compression III/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,33 @@ function compressedString(word: string): string {
209209
}
210210
```
211211

212+
#### JavaScript
213+
214+
```js
215+
/**
216+
* @param {string} word
217+
* @return {string}
218+
*/
219+
var compressedString = function (word) {
220+
const ans = [];
221+
const n = word.length;
222+
for (let i = 0; i < n; ) {
223+
let j = i + 1;
224+
while (j < n && word[j] === word[i]) {
225+
++j;
226+
}
227+
let k = j - i;
228+
while (k) {
229+
const x = Math.min(k, 9);
230+
ans.push(x + word[i]);
231+
k -= x;
232+
}
233+
i = j;
234+
}
235+
return ans.join('');
236+
};
237+
```
238+
212239
<!-- tabs:end -->
213240

214241
<!-- solution:end -->

solution/3100-3199/3163.String Compression III/README_EN.md

+27
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,33 @@ function compressedString(word: string): string {
205205
}
206206
```
207207

208+
#### JavaScript
209+
210+
```js
211+
/**
212+
* @param {string} word
213+
* @return {string}
214+
*/
215+
var compressedString = function (word) {
216+
const ans = [];
217+
const n = word.length;
218+
for (let i = 0; i < n; ) {
219+
let j = i + 1;
220+
while (j < n && word[j] === word[i]) {
221+
++j;
222+
}
223+
let k = j - i;
224+
while (k) {
225+
const x = Math.min(k, 9);
226+
ans.push(x + word[i]);
227+
k -= x;
228+
}
229+
i = j;
230+
}
231+
return ans.join('');
232+
};
233+
```
234+
208235
<!-- tabs:end -->
209236

210237
<!-- solution:end -->

solution/3100-3199/3163.String Compression III/Solution.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* @param {string} word
33
* @return {string}
44
*/
5-
var compressedString = function(word) {
5+
var compressedString = function (word) {
66
const ans = [];
77
const n = word.length;
8-
for (let i = 0; i < n;) {
8+
for (let i = 0; i < n; ) {
99
let j = i + 1;
1010
while (j < n && word[j] === word[i]) {
1111
++j;

solution/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2534,7 +2534,7 @@
25342534
| 2521 | [数组乘积中的不同质因数数目](/solution/2500-2599/2521.Distinct%20Prime%20Factors%20of%20Product%20of%20Array/README.md) | `数组`,`哈希表`,`数学`,`数论` | 中等 | 第 326 场周赛 |
25352535
| 2522 | [将字符串分割成值不超过 K 的子字符串](/solution/2500-2599/2522.Partition%20String%20Into%20Substrings%20With%20Values%20at%20Most%20K/README.md) | `贪心`,`字符串`,`动态规划` | 中等 | 第 326 场周赛 |
25362536
| 2523 | [范围内最接近的两个质数](/solution/2500-2599/2523.Closest%20Prime%20Numbers%20in%20Range/README.md) | `数学`,`数论` | 中等 | 第 326 场周赛 |
2537-
| 2524 | [子数组的最大频率分数](/solution/2500-2599/2524.Maximum%20Frequency%20Score%20of%20a%20Subarray/README.md) | `数组`,`哈希表`,`数学`,`滑动窗口` | 困难 | 🔒 |
2537+
| 2524 | [子数组的最大频率分数](/solution/2500-2599/2524.Maximum%20Frequency%20Score%20of%20a%20Subarray/README.md) | `栈`,`数组`,`哈希表`,`数学`,`滑动窗口` | 困难 | 🔒 |
25382538
| 2525 | [根据规则将箱子分类](/solution/2500-2599/2525.Categorize%20Box%20According%20to%20Criteria/README.md) | `数学` | 简单 | 第 95 场双周赛 |
25392539
| 2526 | [找到数据流中的连续整数](/solution/2500-2599/2526.Find%20Consecutive%20Integers%20from%20a%20Data%20Stream/README.md) | `设计`,`队列`,`哈希表`,`计数`,`数据流` | 中等 | 第 95 场双周赛 |
25402540
| 2527 | [查询数组异或美丽值](/solution/2500-2599/2527.Find%20Xor-Beauty%20of%20Array/README.md) | `位运算`,`数组`,`数学` | 中等 | 第 95 场双周赛 |
@@ -2695,7 +2695,7 @@
26952695
| 2682 | [找出转圈游戏输家](/solution/2600-2699/2682.Find%20the%20Losers%20of%20the%20Circular%20Game/README.md) | `数组`,`哈希表`,`模拟` | 简单 | 第 345 场周赛 |
26962696
| 2683 | [相邻值的按位异或](/solution/2600-2699/2683.Neighboring%20Bitwise%20XOR/README.md) | `位运算`,`数组` | 中等 | 第 345 场周赛 |
26972697
| 2684 | [矩阵中移动的最大次数](/solution/2600-2699/2684.Maximum%20Number%20of%20Moves%20in%20a%20Grid/README.md) | `数组`,`动态规划`,`矩阵` | 中等 | 第 345 场周赛 |
2698-
| 2685 | [统计完全连通分量的数量](/solution/2600-2699/2685.Count%20the%20Number%20of%20Complete%20Components/README.md) | `深度优先搜索`,`广度优先搜索`,`图` | 中等 | 第 345 场周赛 |
2698+
| 2685 | [统计完全连通分量的数量](/solution/2600-2699/2685.Count%20the%20Number%20of%20Complete%20Components/README.md) | `深度优先搜索`,`广度优先搜索`,`并查集`,`图` | 中等 | 第 345 场周赛 |
26992699
| 2686 | [即时食物配送 III](/solution/2600-2699/2686.Immediate%20Food%20Delivery%20III/README.md) | `数据库` | 中等 | 🔒 |
27002700
| 2687 | [自行车的最后使用时间](/solution/2600-2699/2687.Bikes%20Last%20Time%20Used/README.md) | `数据库` | 简单 | 🔒 |
27012701
| 2688 | [查找活跃用户](/solution/2600-2699/2688.Find%20Active%20Users/README.md) | `数据库` | 中等 | 🔒 |

solution/README_EN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2532,7 +2532,7 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
25322532
| 2521 | [Distinct Prime Factors of Product of Array](/solution/2500-2599/2521.Distinct%20Prime%20Factors%20of%20Product%20of%20Array/README_EN.md) | `Array`,`Hash Table`,`Math`,`Number Theory` | Medium | Weekly Contest 326 |
25332533
| 2522 | [Partition String Into Substrings With Values at Most K](/solution/2500-2599/2522.Partition%20String%20Into%20Substrings%20With%20Values%20at%20Most%20K/README_EN.md) | `Greedy`,`String`,`Dynamic Programming` | Medium | Weekly Contest 326 |
25342534
| 2523 | [Closest Prime Numbers in Range](/solution/2500-2599/2523.Closest%20Prime%20Numbers%20in%20Range/README_EN.md) | `Math`,`Number Theory` | Medium | Weekly Contest 326 |
2535-
| 2524 | [Maximum Frequency Score of a Subarray](/solution/2500-2599/2524.Maximum%20Frequency%20Score%20of%20a%20Subarray/README_EN.md) | `Array`,`Hash Table`,`Math`,`Sliding Window` | Hard | 🔒 |
2535+
| 2524 | [Maximum Frequency Score of a Subarray](/solution/2500-2599/2524.Maximum%20Frequency%20Score%20of%20a%20Subarray/README_EN.md) | `Stack`,`Array`,`Hash Table`,`Math`,`Sliding Window` | Hard | 🔒 |
25362536
| 2525 | [Categorize Box According to Criteria](/solution/2500-2599/2525.Categorize%20Box%20According%20to%20Criteria/README_EN.md) | `Math` | Easy | Biweekly Contest 95 |
25372537
| 2526 | [Find Consecutive Integers from a Data Stream](/solution/2500-2599/2526.Find%20Consecutive%20Integers%20from%20a%20Data%20Stream/README_EN.md) | `Design`,`Queue`,`Hash Table`,`Counting`,`Data Stream` | Medium | Biweekly Contest 95 |
25382538
| 2527 | [Find Xor-Beauty of Array](/solution/2500-2599/2527.Find%20Xor-Beauty%20of%20Array/README_EN.md) | `Bit Manipulation`,`Array`,`Math` | Medium | Biweekly Contest 95 |
@@ -2693,7 +2693,7 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
26932693
| 2682 | [Find the Losers of the Circular Game](/solution/2600-2699/2682.Find%20the%20Losers%20of%20the%20Circular%20Game/README_EN.md) | `Array`,`Hash Table`,`Simulation` | Easy | Weekly Contest 345 |
26942694
| 2683 | [Neighboring Bitwise XOR](/solution/2600-2699/2683.Neighboring%20Bitwise%20XOR/README_EN.md) | `Bit Manipulation`,`Array` | Medium | Weekly Contest 345 |
26952695
| 2684 | [Maximum Number of Moves in a Grid](/solution/2600-2699/2684.Maximum%20Number%20of%20Moves%20in%20a%20Grid/README_EN.md) | `Array`,`Dynamic Programming`,`Matrix` | Medium | Weekly Contest 345 |
2696-
| 2685 | [Count the Number of Complete Components](/solution/2600-2699/2685.Count%20the%20Number%20of%20Complete%20Components/README_EN.md) | `Depth-First Search`,`Breadth-First Search`,`Graph` | Medium | Weekly Contest 345 |
2696+
| 2685 | [Count the Number of Complete Components](/solution/2600-2699/2685.Count%20the%20Number%20of%20Complete%20Components/README_EN.md) | `Depth-First Search`,`Breadth-First Search`,`Union Find`,`Graph` | Medium | Weekly Contest 345 |
26972697
| 2686 | [Immediate Food Delivery III](/solution/2600-2699/2686.Immediate%20Food%20Delivery%20III/README_EN.md) | `Database` | Medium | 🔒 |
26982698
| 2687 | [Bikes Last Time Used](/solution/2600-2699/2687.Bikes%20Last%20Time%20Used/README_EN.md) | `Database` | Easy | 🔒 |
26992699
| 2688 | [Find Active Users](/solution/2600-2699/2688.Find%20Active%20Users/README_EN.md) | `Database` | Medium | 🔒 |

0 commit comments

Comments
 (0)