Skip to content

feat: update lc problems #3718

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
merged 2 commits into from
Nov 5, 2024
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
20 changes: 20 additions & 0 deletions solution/0200-0299/0219.Contains Duplicate II/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,26 @@ function containsNearbyDuplicate(nums: number[], k: number): boolean {
}
```

#### JavaScript

```js
/**
* @param {number[]} nums
* @param {number} k
* @return {boolean}
*/
var containsNearbyDuplicate = function (nums, k) {
const d = new Map();
for (let i = 0; i < nums.length; ++i) {
if (d.has(nums[i]) && i - d.get(nums[i]) <= k) {
return true;
}
d.set(nums[i], i);
}
return false;
};
```

#### C#

```cs
Expand Down
20 changes: 20 additions & 0 deletions solution/0200-0299/0219.Contains Duplicate II/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,26 @@ function containsNearbyDuplicate(nums: number[], k: number): boolean {
}
```

#### JavaScript

```js
/**
* @param {number[]} nums
* @param {number} k
* @return {boolean}
*/
var containsNearbyDuplicate = function (nums, k) {
const d = new Map();
for (let i = 0; i < nums.length; ++i) {
if (d.has(nums[i]) && i - d.get(nums[i]) <= k) {
return true;
}
d.set(nums[i], i);
}
return false;
};
```

#### C#

```cs
Expand Down
2 changes: 1 addition & 1 deletion solution/0200-0299/0219.Contains Duplicate II/Solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @param {number} k
* @return {boolean}
*/
var containsNearbyDuplicate = function(nums, k) {
var containsNearbyDuplicate = function (nums, k) {
const d = new Map();
for (let i = 0; i < nums.length; ++i) {
if (d.has(nums[i]) && i - d.get(nums[i]) <= k) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/2500-2599/2524.Maximum%20Frequency%20Score%20of%20a%20Subarray/README.md
tags:
- 栈
- 数组
- 哈希表
- 数学
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/2500-2599/2524.Maximum%20Frequency%20Score%20of%20a%20Subarray/README_EN.md
tags:
- Stack
- Array
- Hash Table
- Math
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ source: 第 345 场周赛 Q4
tags:
- 深度优先搜索
- 广度优先搜索
- 并查集
- 图
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ source: Weekly Contest 345 Q4
tags:
- Depth-First Search
- Breadth-First Search
- Union Find
- Graph
---

Expand Down
27 changes: 27 additions & 0 deletions solution/3100-3199/3163.String Compression III/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,33 @@ function compressedString(word: string): string {
}
```

#### JavaScript

```js
/**
* @param {string} word
* @return {string}
*/
var compressedString = function (word) {
const ans = [];
const n = word.length;
for (let i = 0; i < n; ) {
let j = i + 1;
while (j < n && word[j] === word[i]) {
++j;
}
let k = j - i;
while (k) {
const x = Math.min(k, 9);
ans.push(x + word[i]);
k -= x;
}
i = j;
}
return ans.join('');
};
```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
27 changes: 27 additions & 0 deletions solution/3100-3199/3163.String Compression III/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,33 @@ function compressedString(word: string): string {
}
```

#### JavaScript

```js
/**
* @param {string} word
* @return {string}
*/
var compressedString = function (word) {
const ans = [];
const n = word.length;
for (let i = 0; i < n; ) {
let j = i + 1;
while (j < n && word[j] === word[i]) {
++j;
}
let k = j - i;
while (k) {
const x = Math.min(k, 9);
ans.push(x + word[i]);
k -= x;
}
i = j;
}
return ans.join('');
};
```

<!-- tabs:end -->

<!-- solution:end -->
Expand Down
4 changes: 2 additions & 2 deletions solution/3100-3199/3163.String Compression III/Solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* @param {string} word
* @return {string}
*/
var compressedString = function(word) {
var compressedString = function (word) {
const ans = [];
const n = word.length;
for (let i = 0; i < n;) {
for (let i = 0; i < n; ) {
let j = i + 1;
while (j < n && word[j] === word[i]) {
++j;
Expand Down
4 changes: 2 additions & 2 deletions solution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2534,7 +2534,7 @@
| 2521 | [数组乘积中的不同质因数数目](/solution/2500-2599/2521.Distinct%20Prime%20Factors%20of%20Product%20of%20Array/README.md) | `数组`,`哈希表`,`数学`,`数论` | 中等 | 第 326 场周赛 |
| 2522 | [将字符串分割成值不超过 K 的子字符串](/solution/2500-2599/2522.Partition%20String%20Into%20Substrings%20With%20Values%20at%20Most%20K/README.md) | `贪心`,`字符串`,`动态规划` | 中等 | 第 326 场周赛 |
| 2523 | [范围内最接近的两个质数](/solution/2500-2599/2523.Closest%20Prime%20Numbers%20in%20Range/README.md) | `数学`,`数论` | 中等 | 第 326 场周赛 |
| 2524 | [子数组的最大频率分数](/solution/2500-2599/2524.Maximum%20Frequency%20Score%20of%20a%20Subarray/README.md) | `数组`,`哈希表`,`数学`,`滑动窗口` | 困难 | 🔒 |
| 2524 | [子数组的最大频率分数](/solution/2500-2599/2524.Maximum%20Frequency%20Score%20of%20a%20Subarray/README.md) | `栈`,`数组`,`哈希表`,`数学`,`滑动窗口` | 困难 | 🔒 |
| 2525 | [根据规则将箱子分类](/solution/2500-2599/2525.Categorize%20Box%20According%20to%20Criteria/README.md) | `数学` | 简单 | 第 95 场双周赛 |
| 2526 | [找到数据流中的连续整数](/solution/2500-2599/2526.Find%20Consecutive%20Integers%20from%20a%20Data%20Stream/README.md) | `设计`,`队列`,`哈希表`,`计数`,`数据流` | 中等 | 第 95 场双周赛 |
| 2527 | [查询数组异或美丽值](/solution/2500-2599/2527.Find%20Xor-Beauty%20of%20Array/README.md) | `位运算`,`数组`,`数学` | 中等 | 第 95 场双周赛 |
Expand Down Expand Up @@ -2695,7 +2695,7 @@
| 2682 | [找出转圈游戏输家](/solution/2600-2699/2682.Find%20the%20Losers%20of%20the%20Circular%20Game/README.md) | `数组`,`哈希表`,`模拟` | 简单 | 第 345 场周赛 |
| 2683 | [相邻值的按位异或](/solution/2600-2699/2683.Neighboring%20Bitwise%20XOR/README.md) | `位运算`,`数组` | 中等 | 第 345 场周赛 |
| 2684 | [矩阵中移动的最大次数](/solution/2600-2699/2684.Maximum%20Number%20of%20Moves%20in%20a%20Grid/README.md) | `数组`,`动态规划`,`矩阵` | 中等 | 第 345 场周赛 |
| 2685 | [统计完全连通分量的数量](/solution/2600-2699/2685.Count%20the%20Number%20of%20Complete%20Components/README.md) | `深度优先搜索`,`广度优先搜索`,`图` | 中等 | 第 345 场周赛 |
| 2685 | [统计完全连通分量的数量](/solution/2600-2699/2685.Count%20the%20Number%20of%20Complete%20Components/README.md) | `深度优先搜索`,`广度优先搜索`,`并查集`,`图` | 中等 | 第 345 场周赛 |
| 2686 | [即时食物配送 III](/solution/2600-2699/2686.Immediate%20Food%20Delivery%20III/README.md) | `数据库` | 中等 | 🔒 |
| 2687 | [自行车的最后使用时间](/solution/2600-2699/2687.Bikes%20Last%20Time%20Used/README.md) | `数据库` | 简单 | 🔒 |
| 2688 | [查找活跃用户](/solution/2600-2699/2688.Find%20Active%20Users/README.md) | `数据库` | 中等 | 🔒 |
Expand Down
4 changes: 2 additions & 2 deletions solution/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2532,7 +2532,7 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
| 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 |
| 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 |
| 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 |
| 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 | 🔒 |
| 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 | 🔒 |
| 2525 | [Categorize Box According to Criteria](/solution/2500-2599/2525.Categorize%20Box%20According%20to%20Criteria/README_EN.md) | `Math` | Easy | Biweekly Contest 95 |
| 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 |
| 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 |
Expand Down Expand Up @@ -2693,7 +2693,7 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
| 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 |
| 2683 | [Neighboring Bitwise XOR](/solution/2600-2699/2683.Neighboring%20Bitwise%20XOR/README_EN.md) | `Bit Manipulation`,`Array` | Medium | Weekly Contest 345 |
| 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 |
| 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 |
| 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 |
| 2686 | [Immediate Food Delivery III](/solution/2600-2699/2686.Immediate%20Food%20Delivery%20III/README_EN.md) | `Database` | Medium | 🔒 |
| 2687 | [Bikes Last Time Used](/solution/2600-2699/2687.Bikes%20Last%20Time%20Used/README_EN.md) | `Database` | Easy | 🔒 |
| 2688 | [Find Active Users](/solution/2600-2699/2688.Find%20Active%20Users/README_EN.md) | `Database` | Medium | 🔒 |
Expand Down
Loading