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

Commit 841f131

Browse files
chore: update lc problems (#1394)
1 parent 4fe30d8 commit 841f131

File tree

6 files changed

+105
-97
lines changed

6 files changed

+105
-97
lines changed

‎solution/2800-2899/2802.Find The K-th Lucky Number/README.md‎

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
1-
# [2802. Find The K-th Lucky Number](https://leetcode.cn/problems/find-the-k-th-lucky-number)
1+
# [2802. 找出第 K 个幸运数字](https://leetcode.cn/problems/find-the-k-th-lucky-number)
22

33
[English Version](/solution/2800-2899/2802.Find%20The%20K-th%20Lucky%20Number/README_EN.md)
44

55
## 题目描述
66

77
<!-- 这里写题目描述 -->
88

9-
<p>We know that <code>4</code> and <code>7</code> are <strong>lucky</strong> digits. Also, a number is called <strong>lucky</strong>&nbsp;if it contains <strong>only</strong> lucky digits.</p>
9+
<p>我们知道 <code>4</code> <code>7</code> <strong>幸运</strong> 数字。同时,如果一个数字只包含幸运数字,那么它被称为幸运数字。</p>
1010

11-
<p>You are given an integer <code>k</code>, return<em> the </em><code>k<sup>th</sup></code><em>&nbsp;lucky number represented as a <strong>string</strong>.</em></p>
11+
<p>给定一个整数 <code>k</code>,返回第 <code>k</code> 个幸运数字,并将其表示为一个 <strong>字符串</strong></p>
1212

1313
<p>&nbsp;</p>
14-
<p><strong class="example">Example 1:</strong></p>
14+
15+
<p><strong class="example">示例 1:</strong></p>
1516

1617
<pre>
17-
<strong>Input:</strong>k = 4
18-
<strong>Output:</strong> &quot;47&quot;
19-
<strong>Explanation:</strong> The first lucky number is 4, the second one is 7, the third one is 44 and the fourth one is 47.
18+
<strong>输入:</strong>k = 4
19+
<b>输出:</b>"47"
20+
<b>解释:</b>第一个幸运数字是 4,第二个是 7,第三个是 44,第四个是 47。
2021
</pre>
2122

22-
<p><strong class="example">Example 2:</strong></p>
23+
<p><strong class="example">示例 2:</strong></p>
2324

2425
<pre>
25-
<strong>Input:</strong> k = 10
26-
<strong>Output:</strong> &quot;477&quot;
27-
<strong>Explanation:</strong> Here are lucky numbers sorted in increasing order:
28-
4, 7, 44, 47, 74, 77, 444, 447, 474, 477. So the 10<sup>th</sup> lucky number is 477.</pre>
26+
<b>输入:</b>k = 10
27+
<b>输出:</b>"477"
28+
<b>解释:</b>按递增顺序列出的幸运数字为:
29+
4, 7, 44, 47, 74, 77, 444, 447, 474, 477。 因此第10个幸运数字是477。</pre>
2930

30-
<p><strong class="example">Example 3:</strong></p>
31+
<p><strong class="example">示例 3:</strong></p>
3132

3233
<pre>
33-
<strong>Input:</strong> k = 1000
34-
<strong>Output:</strong> &quot;777747447&quot;
35-
<strong>Explanation:</strong> It can be shown that the 1000<sup>th</sup> lucky number is 777747447.
34+
<b>输入:</b>k = 1000
35+
<b>输出:</b>"777747447"
36+
<b>解释:</b>第 1000 个幸运数字是 777747447
3637
</pre>
3738

3839
<p>&nbsp;</p>
39-
<p><strong>Constraints:</strong></p>
40+
41+
<p><strong>提示:</strong></p>
4042

4143
<ul>
4244
<li><code>1 &lt;= k &lt;= 10<sup>9</sup></code></li>

‎solution/2800-2899/2803.Factorial Generator/README.md‎

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
# [2803. Factorial Generator](https://leetcode.cn/problems/factorial-generator)
1+
# [2803. 阶乘生成器](https://leetcode.cn/problems/factorial-generator)
22

33
[English Version](/solution/2800-2899/2803.Factorial%20Generator/README_EN.md)
44

55
## 题目描述
66

77
<!-- 这里写题目描述 -->
88

9-
<p>Write a generator function that takes an integer <code>n</code> as an argument and returns a generator object which yields the <strong>factorial sequence</strong>.</p>
9+
<p>编写一个生成器函数,该函数以一个整数 <code>n</code> 作为参数,并返回一个生成器对象,该生成器对象可以生成 <strong>阶乘序列</strong></p>
1010

11-
<p>The&nbsp;<strong>factorial sequence</strong>&nbsp;is defined by the relation <code>n!&nbsp;= n *&nbsp;<spanstyle="font-size: 13px;">(</span>n-1)&nbsp;* (n-2)&nbsp;*&nbsp;...&nbsp;* 2 * 1​​​.</code></p>
11+
<p><strong>阶乘序列</strong> 的定义如下:<code>n!= n * (n-1)* (n-2) * ...* 2 * 1</code>&nbsp;</p>
1212

13-
<p>The factorial of 0 is defined as 1.</p>
13+
<p>0 的阶乘被定义为 1。</p>
1414

1515
<p>&nbsp;</p>
16-
<p><strong class="example">Example 1:</strong></p>
16+
17+
<p><strong class="example">示例 1:</strong></p>
1718

1819
<pre>
19-
<strong>Input:</strong> n = 5
20-
<strong>Output:</strong> [1,2,6,24,120]
21-
<strong>Explanation:</strong>
20+
<b>输入:</b>n = 5
21+
<b>输出:</b>[1,2,6,24,120]
22+
<b>解释:</b>
2223
const gen = factorial(5)
2324
gen.next().value // 1
2425
gen.next().value // 2
@@ -27,29 +28,30 @@ gen.next().value // 24
2728
gen.next().value // 120
2829
</pre>
2930

30-
<p><strong class="example">Example 2:</strong></p>
31+
<p><strong class="example">示例 2:</strong></p>
3132

3233
<pre>
33-
<strong>Input:</strong> n = 2
34-
<strong>Output:</strong> [1,2]
35-
<strong>Explanation:</strong>
34+
<b>输入:</b>n = 2
35+
<b>输出:</b>[1,2]
36+
<b>解释:</b>
3637
const gen = factorial(2)
3738
gen.next().value // 1
3839
gen.next().value // 2
3940
</pre>
4041

41-
<p><strong class="example">Example 3:</strong></p>
42+
<p><strong class="example">示例 3:</strong></p>
4243

4344
<pre>
44-
<strong>Input:</strong> n = 0
45-
<strong>Output:</strong> [1]
46-
<strong>Explanation:</strong>
45+
<b>输入:</b>n = 0
46+
<b>输出:</b>[1]
47+
<b>解释:</b>
4748
const gen = factorial(0)
4849
gen.next().value // 1
4950
</pre>
5051

5152
<p>&nbsp;</p>
52-
<p><strong>Constraints:</strong></p>
53+
54+
<p><strong>提示:</strong></p>
5355

5456
<ul>
5557
<li><code>0 &lt;= n &lt;= 18</code></li>

‎solution/2800-2899/2804.Array Prototype ForEach/README.md‎

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,75 @@
1-
# [2804. Array Prototype ForEach](https://leetcode.cn/problems/array-prototype-foreach)
1+
# [2804. 数组原型的 forEach 方法](https://leetcode.cn/problems/array-prototype-foreach)
22

33
[English Version](/solution/2800-2899/2804.Array%20Prototype%20ForEach/README_EN.md)
44

55
## 题目描述
66

77
<!-- 这里写题目描述 -->
88

9-
<p>Write your version of method&nbsp;<code>forEach</code>&nbsp;that enhances all arrays such that you can call the&nbsp;<code>array.forEach(callback, context)</code>&nbsp;method on any array and it will execute <code>callback</code> on each element of the array.&nbsp;Method&nbsp;<code>forEach</code> should not return anything.</p>
9+
<p>编写一个数组方法 <code>forEach</code>,使其可以在任何数组上调用 <code>array.forEach(callback, context)</code> 方法,它将在数组的每个元素上执行回调函数。<code>forEach</code> 方法不应该返回任何内容。</p>
1010

11-
<p><code>callback</code> accepts the following arguments:</p>
11+
<p>回调函数 <code>callback</code> 接受以下参数:</p>
1212

1313
<ul>
14-
<li><code>value</code> -&nbsp;represents the current element being processed in the array. It is the value of the element in the current iteration.</li>
15-
<li><code>index</code> -&nbsp;represents the index of the current element being processed in the array.</li>
16-
<li><code>array</code> -&nbsp;represents the array itself, allowing access to the entire array within the callback function.</li>
14+
<li><code>value</code> - 表示数组中当前正在处理的元素的值。</li>
15+
<li><code>index</code> - 表示数组中当前正在处理的元素的索引。</li>
16+
<li><code>array</code> - 表示数组本身,在回调函数内部可以访问整个数组。</li>
1717
</ul>
1818

19-
<p>The <code>context</code> is the object that should be passed as the function context parameter to the <code>callback</code> function, ensuring that the <code>this</code>&nbsp;keyword within the <code>callback</code> function refers to this <code>context</code> object.</p>
19+
<p>上下文 <code>context</code> 应该是作为函数上下文参数传递给回调函数的对象,确保回调函数内部的 <code>this</code> 关键字引用此上下文对象。</p>
2020

21-
<p>Try to implement it without using the built-in array methods.</p>
21+
<p>尝试在不使用内置数组方法的情况下实现这个方法。</p>
2222

2323
<p>&nbsp;</p>
24-
<p><strong class="example">Example 1:</strong></p>
24+
25+
<p><b>示例 1:</b></p>
2526

2627
<pre>
27-
<strong>Input:</strong>
28+
<b>输入:</b>
2829
arr = [1,2,3],
2930
callback = (val, i, arr) =&gt; arr[i] = val * 2,
30-
context = {&quot;context&quot;:true}
31-
<strong>Output:</strong> [2,4,6]
32-
<strong>Explanation:</strong>
31+
context = {"context":true}
32+
<b>输出:</b>[2,4,6]
33+
<b>解释:</b>
3334
arr.forEach(callback, context)&nbsp;
3435
console.log(arr) // [2,4,6]
3536

36-
The callback is executed on each element of the array.
37+
回调函数在数组的每个元素上执行。
3738
</pre>
3839

39-
<p><strong class="example">Example 2:</strong></p>
40+
<p><strong class="example">示例 2:</strong></p>
4041

4142
<pre>
42-
<strong>Input:</strong>
43+
<b>输入:</b>
4344
arr = [true, true, false, false],
4445
callback = (val, i, arr) =&gt; arr[i] = this,
45-
context = {&quot;context&quot;: false}
46-
<strong>Output:</strong> [{&quot;context&quot;:false},{&quot;context&quot;:false},{&quot;context&quot;:false},{&quot;context&quot;:false}]
47-
<strong>Explanation:</strong>
46+
context = {"context": false}
47+
<b>输出:</b>[{"context":false},{"context":false},{"context":false},{"context":false}]
48+
<b>解释:</b>
4849
arr.forEach(callback, context)&nbsp;
49-
console.log(arr) // [{&quot;context&quot;:false},{&quot;context&quot;:false},{&quot;context&quot;:false},{&quot;context&quot;:false}]
50+
console.log(arr) // [{"context":false},{"context":false},{"context":false},{"context":false}]
5051

51-
The callback is executed on each element of the array with the right context.
52+
回调函数在数组的每个元素上以正确的上下文执行。
5253
</pre>
5354

54-
<p><strong class="example">Example 3:</strong></p>
55+
<p><strong class="example">示例 3:</strong></p>
5556

5657
<pre>
57-
<strong>Input:</strong>
58+
<b>输入:</b>
5859
arr = [true, true, false, false],
5960
callback = (val, i, arr) =&gt; arr[i] = !val,
60-
context = {&quot;context&quot;: 5}
61-
<strong>Output:</strong> [false,false,true,true]
61+
context = {"context": 5}
62+
<b>输出:</b>[false,false,true,true]
6263
</pre>
6364

6465
<p>&nbsp;</p>
65-
<p><strong>Constraints:</strong></p>
66+
67+
<p><strong>提示:</strong></p>
6668

6769
<ul>
68-
<li><code>arr</code> is a valid JSON array</li>
69-
<li><code>context</code> is a valid JSON object</li>
70-
<li><code>fn</code> is a function</li>
70+
<li><code>arr</code> 是一个有效的 JSON 数组</li>
71+
<li><code>context</code> 是一个有效的 JSON 对象</li>
72+
<li><code>fn</code>&nbsp;是一个函数</li>
7173
<li><code>0 &lt;= arr.length &lt;= 10<sup>5</sup></code></li>
7274
</ul>
7375

‎solution/2800-2899/2805.Custom Interval/README.md‎

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
# [2805. Custom Interval](https://leetcode.cn/problems/custom-interval)
1+
# [2805. 自定义间隔](https://leetcode.cn/problems/custom-interval)
22

33
[English Version](/solution/2800-2899/2805.Custom%20Interval/README_EN.md)
44

55
## 题目描述
66

77
<!-- 这里写题目描述 -->
88

9-
<p><strong>Function&nbsp;</strong><code>customInterval</code></p>
9+
<p><strong>函数</strong>&nbsp;<code>customInterval</code></p>
1010

11-
<p>Given a function <code>fn</code>, a number <code>delay</code> and a number <code>period</code>, return&nbsp;a number&nbsp;<code>id</code>. <code>customInterval</code>&nbsp;is a function that should execute the provided function <code>fn</code> at intervals based on a linear pattern defined by the formula <code>delay&nbsp;+ period&nbsp;* count</code>.&nbsp;The <code>count</code> in the formula&nbsp;represents the number of times the interval has been&nbsp;executed starting from an initial value of 0.</p>
11+
<p>给定一个函数 <code>fn</code>、一个数字 <code>delay</code> 和一个数字 <code>period</code>,返回一个数字 <code>id</code><code>customInterval</code> 是一个函数,它应该根据公式 <code>delay + period * count</code> 在间隔中执行提供的函数 <code>fn</code>,公式中的 <code>count</code> 表示从初始值 0 开始执行间隔的次数。</p>
1212

13-
<p><strong>Function </strong><code>customClearInterval</code>&nbsp;</p>
13+
<p><strong>函数</strong><code>customClearInterval</code></p>
1414

15-
<p>Given the&nbsp;<code>id</code>. <code>id</code>&nbsp;is the&nbsp;returned value from&nbsp;the function&nbsp;<code>customInterval</code>. <code>customClearInterval</code>&nbsp;should stop executing&nbsp;provided function <code>fn</code> at intervals.</p>
15+
<p>给定 <code>id</code><code>id</code> 是从函数 <code>customInterval</code> 返回的值。<code>customClearInterval</code> 应该停止在间隔中执行提供的函数 <code>fn</code></p>
1616

1717
<p>&nbsp;</p>
18-
<p><strong class="example">Example 1:</strong></p>
18+
19+
<p><b>示例 1:</b></p>
1920

2021
<pre>
21-
<strong>Input:</strong> delay = 50, period = 20, stopTime = 225
22-
<strong>Output:</strong> [50,120,210]
23-
<strong>Explanation:</strong>
22+
<b>输入:</b>delay = 50, period = 20, stopTime = 225
23+
<b>输出:</b>[50,120,210]
24+
<b>解释:</b>
2425
const t = performance.now()&nbsp;&nbsp;
2526
const result = []
2627
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
@@ -33,34 +34,35 @@ setTimeout(() =&gt; {
3334
customClearInterval(id)
3435
}, 225)
3536

36-
50 + 20 * 0 = 50 // 50ms - 1st function call
37-
50 + 20&nbsp;* 1 = 70 // 50ms + 70ms = 120ms - 2nd function call
38-
50 + 20 * 2 = 90 // 50ms + 70ms + 90ms = 210ms - 3rd function call
37+
50 + 20 * 0 = 50 // 50ms - 第一个函数调用
38+
50 + 20&nbsp;* 1 = 70 // 50ms + 70ms = 120ms - 第二个函数调用
39+
50 + 20 * 2 = 90 // 50ms + 70ms + 90ms = 210ms - 第三个函数调用
3940
</pre>
4041

41-
<p><strong class="example">Example 2:</strong></p>
42+
<p><strong class="example">示例 2:</strong></p>
4243

4344
<pre>
44-
<strong>Input:</strong> delay = 20, period = 20, stopTime = 150
45-
<strong>Output:</strong> [20,60,120]
46-
<strong>Explanation:</strong>
47-
20 + 20 * 0 = 20 // 20ms - 1st function call
48-
20 + 20&nbsp;* 1 = 40 // 20ms + 40ms = 60ms - 2nd function call
49-
20 + 20 * 2 = 60 // 20ms + 40ms + 60ms = 120ms - 3rd function call
45+
<b>输入:</b>delay = 20, period = 20, stopTime = 150
46+
<b>输出:</b>[20,60,120]
47+
<b>解释:</b>
48+
20 + 20 * 0 = 20 // 20ms - 第一个函数调用
49+
20 + 20&nbsp;* 1 = 40 // 20ms + 40ms = 60ms - 第二个函数调用
50+
20 + 20 * 2 = 60 // 20ms + 40ms + 60ms = 120ms - 第三个函数调用
5051
</pre>
5152

52-
<p><strong class="example">Example 3:</strong></p>
53+
<p><strong class="example">示例 3:</strong></p>
5354

5455
<pre>
55-
<strong>Input:</strong> delay = 100, period = 200, stopTime = 500
56-
<strong>Output:</strong> [100,400]
57-
<strong>Explanation:</strong>
58-
100 + 200 * 0 = 100 // 100ms - 1st function call
59-
100 + 200&nbsp;* 1 = 300 // 100ms + 300ms = 400ms - 2nd function call
56+
<b>输入:</b>delay = 100, period = 200, stopTime = 500
57+
<b>输出:</b>[100,400]
58+
<b>解释:</b>
59+
100 + 200 * 0 = 100 // 100ms - 第一个函数调用
60+
100 + 200&nbsp;* 1 = 300 // 100ms + 300ms = 400ms - 第二个函数调用
6061
</pre>
6162

6263
<p>&nbsp;</p>
63-
<p><strong>Constraints:</strong></p>
64+
65+
<p><strong>提示:</strong></p>
6466

6567
<ul>
6668
<li><code>20 &lt;= delay, period &lt;= 250</code></li>

‎solution/README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2812,10 +2812,10 @@
28122812
| 2799 | [统计完全子数组的数目](/solution/2700-2799/2799.Count%20Complete%20Subarrays%20in%20an%20Array/README.md) | `数组`,`哈希表`,`滑动窗口` | 中等 | 第 356 场周赛 |
28132813
| 2800 | [包含三个字符串的最短字符串](/solution/2800-2899/2800.Shortest%20String%20That%20Contains%20Three%20Strings/README.md) | `贪心`,`字符串`,`枚举` | 中等 | 第 356 场周赛 |
28142814
| 2801 | [统计范围内的步进数字数目](/solution/2800-2899/2801.Count%20Stepping%20Numbers%20in%20Range/README.md) | `字符串`,`动态规划` | 困难 | 第 356 场周赛 |
2815-
| 2802 | [Find The K-th Lucky Number](/solution/2800-2899/2802.Find%20The%20K-th%20Lucky%20Number/README.md) | | 中等 | 🔒 |
2816-
| 2803 | [Factorial Generator](/solution/2800-2899/2803.Factorial%20Generator/README.md) | | 简单 | 🔒 |
2817-
| 2804 | [Array Prototype ForEach](/solution/2800-2899/2804.Array%20Prototype%20ForEach/README.md) | | 简单 | 🔒 |
2818-
| 2805 | [Custom Interval](/solution/2800-2899/2805.Custom%20Interval/README.md) | | 中等 | 🔒 |
2815+
| 2802 | [找出第 K 个幸运数字](/solution/2800-2899/2802.Find%20The%20K-th%20Lucky%20Number/README.md) | | 中等 | 🔒 |
2816+
| 2803 | [阶乘生成器](/solution/2800-2899/2803.Factorial%20Generator/README.md) | | 简单 | 🔒 |
2817+
| 2804 | [数组原型的 forEach 方法](/solution/2800-2899/2804.Array%20Prototype%20ForEach/README.md) | | 简单 | 🔒 |
2818+
| 2805 | [自定义间隔](/solution/2800-2899/2805.Custom%20Interval/README.md) | | 中等 | 🔒 |
28192819

28202820
## 版权
28212821

‎solution/summary.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,7 +2857,7 @@
28572857
- 2800-2899
28582858
- [2800.包含三个字符串的最短字符串](/solution/2800-2899/2800.Shortest%20String%20That%20Contains%20Three%20Strings/README.md)
28592859
- [2801.统计范围内的步进数字数目](/solution/2800-2899/2801.Count%20Stepping%20Numbers%20in%20Range/README.md)
2860-
- [2802.Find The K-th Lucky Number](/solution/2800-2899/2802.Find%20The%20K-th%20Lucky%20Number/README.md)
2861-
- [2803.Factorial Generator](/solution/2800-2899/2803.Factorial%20Generator/README.md)
2862-
- [2804.Array Prototype ForEach](/solution/2800-2899/2804.Array%20Prototype%20ForEach/README.md)
2863-
- [2805.Custom Interval](/solution/2800-2899/2805.Custom%20Interval/README.md)
2860+
- [2802.找出第 K 个幸运数字](/solution/2800-2899/2802.Find%20The%20K-th%20Lucky%20Number/README.md)
2861+
- [2803.阶乘生成器](/solution/2800-2899/2803.Factorial%20Generator/README.md)
2862+
- [2804.数组原型的 forEach 方法](/solution/2800-2899/2804.Array%20Prototype%20ForEach/README.md)
2863+
- [2805.自定义间隔](/solution/2800-2899/2805.Custom%20Interval/README.md)

0 commit comments

Comments
(0)

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