Skip to content

Commit 3d74b5a

Browse files
authored
chore: update lc problems (doocs#2120)
1 parent 468e051 commit 3d74b5a

File tree

31 files changed

+100
-74
lines changed

31 files changed

+100
-74
lines changed

solution/0100-0199/0167.Two Sum II - Input Array Is Sorted/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Description
66

7-
<p>Given a <strong>1-indexed</strong> array of integers <code>numbers</code> that is already <strong><em>sorted in non-decreasing order</em></strong>, find two numbers such that they add up to a specific <code>target</code> number. Let these two numbers be <code>numbers[index<sub>1</sub>]</code> and <code>numbers[index<sub>2</sub>]</code> where <code>1 &lt;= index<sub>1</sub> &lt; index<sub>2</sub> &lt;&nbsp;numbers.length</code>.</p>
7+
<p>Given a <strong>1-indexed</strong> array of integers <code>numbers</code> that is already <strong><em>sorted in non-decreasing order</em></strong>, find two numbers such that they add up to a specific <code>target</code> number. Let these two numbers be <code>numbers[index<sub>1</sub>]</code> and <code>numbers[index<sub>2</sub>]</code> where <code>1 &lt;= index<sub>1</sub> &lt; index<sub>2</sub> &lt;= numbers.length</code>.</p>
88

99
<p>Return<em> the indices of the two numbers, </em><code>index<sub>1</sub></code><em> and </em><code>index<sub>2</sub></code><em>, <strong>added by one</strong> as an integer array </em><code>[index<sub>1</sub>, index<sub>2</sub>]</code><em> of length 2.</em></p>
1010

solution/1100-1199/1160.Find Words That Can Be Formed by Characters/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<p>You are given an array of strings <code>words</code> and a string <code>chars</code>.</p>
88

9-
<p>A string is <strong>good</strong> if it can be formed by characters from chars (each character can only be used once).</p>
9+
<p>A string is <strong>good</strong> if it can be formed by characters from <code>chars</code> (each character can only be used once).</p>
1010

1111
<p>Return <em>the sum of lengths of all good strings in words</em>.</p>
1212

solution/2500-2599/2563.Count the Number of Fair Pairs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<pre>
3131
<b>输入:</b>nums = [1,7,9,2,5], lower = 11, upper = 11
3232
<b>输出:</b>1
33-
<b>解释:</b>只有单个公平数对:(2,3) 。
33+
<b>解释:</b>只有单个公平数对:(2,9) 。
3434
</pre>
3535

3636
<p>&nbsp;</p>

solution/2600-2699/2693.Call Function with Custom Context/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ args = [{&quot;item&quot;: &quot;burger&quot;}, 10, 1.1]
5151
<p>&nbsp;</p>
5252
<p><strong>Constraints:</strong></p>
5353

54-
<ul style="list-style-type:square;">
54+
<ul>
5555
<li><code><font face="monospace">typeof args[0] == &#39;object&#39; and args[0] != null</font></code></li>
5656
<li><code>1 &lt;= args.length &lt;= 100</code></li>
5757
<li><code>2 &lt;= JSON.stringify(args[0]).length &lt;= 10<sup>5</sup></code></li>

solution/2700-2799/2700.Differences Between Two Objects/README_EN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
<p>Write a function that accepts two deeply nested objects or arrays&nbsp;<code>obj1</code> and&nbsp;<code>obj2</code>&nbsp;and returns a new&nbsp;object representing their differences.</p>
88

9-
<p>The function should compare the properties of the two objects and identify any changes.&nbsp;The returned object should only contains keys where the value is different from&nbsp;<code>obj1</code> to&nbsp;<code>obj2</code>. For each changed key, the value should be represented as an&nbsp;array <code>[obj1 value, obj2&nbsp;value]</code>. Keys that exist in one object but not in the other should not be included in the returned object. When comparing two arrays, the indices of the arrays are considered to be their keys.&nbsp;The end result should be a deeply nested object where each leaf value is a difference array.</p>
9+
<p>The function should compare the properties of the two objects and identify any changes.&nbsp;The returned object should only contains keys where the value is different from&nbsp;<code>obj1</code> to&nbsp;<code>obj2</code>.</p>
10+
11+
<p>For each changed key, the value should be represented as an&nbsp;array <code>[obj1 value, obj2&nbsp;value]</code>. Keys that exist in one object but not in the other should not be included in the returned object. When comparing two arrays, the indices of the arrays are considered to be their keys.&nbsp;The end result should be a deeply nested object where each leaf value is a difference array.</p>
1012

1113
<p>You may assume that both objects are the output of <code>JSON.parse</code>.</p>
1214

solution/2700-2799/2715.Timeout Cancellation/README_EN.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,8 @@ setTimeout(cancelFn, cancelTimeMs)
2424
<strong>Output:</strong> [{&quot;time&quot;: 20, &quot;returned&quot;: 10}]
2525
<strong>Explanation:</strong>
2626
const cancelTimeMs = 50;
27-
const result = [];
28-
29-
const fn = (x) =&gt; x * 5;
30-
31-
const start = performance.now();
32-
33-
const log = (...argsArr) =&gt; {
34-
const diff = Math.floor(performance.now() - start);
35-
result.push({&quot;time&quot;: diff, &quot;returned&quot;: fn(...argsArr)});
36-
}
37-
&nbsp; &nbsp;&nbsp;
38-
const cancel = cancellable(log, [2], 20);
39-
40-
const maxT = Math.max(t, 50);
41-
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
42-
setTimeout(cancel, cancelTimeMs);
43-
44-
setTimeout(() =&gt; {
45-
&nbsp; &nbsp; console.log(result); // [{&quot;time&quot;:20,&quot;returned&quot;:10}]
46-
}, maxT + 15);
27+
const cancelFn = cancellable((x) =&gt; x * 5, [2], 20);
28+
setTimeout(cancelFn, cancelTimeMs);
4729

4830
The cancellation was scheduled to occur after a delay of cancelTimeMs (50ms), which happened after the execution of fn(2) at 20ms.
4931
</pre>
@@ -55,6 +37,9 @@ The cancellation was scheduled to occur after a delay of cancelTimeMs (50ms), wh
5537
<strong>Output:</strong> []
5638
<strong>Explanation:</strong>
5739
const cancelTimeMs = 50;
40+
const cancelFn = cancellable((x) =&gt; x**2, [2], 100);
41+
setTimeout(cancelFn, cancelTimeMs);
42+
5843
The cancellation was scheduled to occur after a delay of cancelTimeMs (50ms), which happened before the execution of fn(2) at 100ms, resulting in fn(2) never being called.
5944
</pre>
6045

@@ -65,6 +50,9 @@ The cancellation was scheduled to occur after a delay of cancelTimeMs (50ms), wh
6550
<strong>Output:</strong> [{&quot;time&quot;: 30, &quot;returned&quot;: 8}]
6651
<strong>Explanation:
6752
</strong>const cancelTimeMs = 100;
53+
const cancelFn = cancellable((x1, x2) =&gt; x1 * x2, [2,4], 30);
54+
setTimeout(cancelFn, cancelTimeMs);
55+
6856
The cancellation was scheduled to occur after a delay of cancelTimeMs (100ms), which happened after the execution of fn(2,4) at 30ms.
6957
</pre>
7058

solution/2700-2799/2724.Sort By/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
<p><strong>Constraints:</strong></p>
3838

3939
<ul>
40-
<li><code>arr is a valid JSON array</code></li>
41-
<li><code>fn is a function that returns a number</code></li>
40+
<li><code>arr</code> is a valid JSON array</li>
41+
<li><code>fn</code> is a function that returns a number</li>
4242
<li><code>1 &lt;=&nbsp;arr.length &lt;= 5 * 10<sup>5</sup></code></li>
4343
</ul>
4444

solution/2700-2799/2725.Interval Cancellation/README_EN.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,9 @@
2323
{&quot;time&quot;: 175, &quot;returned&quot;: 8}
2424
]
2525
<strong>Explanation:</strong>
26-
const result = [];
27-
const fn = (x) =&gt; x * 2;
2826
const cancelTimeMs = 190;
29-
30-
const start = performance.now();
31-
32-
const log = (...argsArr) =&gt; {
33-
const diff = Math.floor(performance.now() - start);
34-
result.push({&quot;time&quot;: diff, &quot;returned&quot;: fn(...argsArr)});
35-
}
36-
37-
const cancel = cancellable(log, [4], 35);
38-
setTimeout(cancel, cancelTimeMs);
39-
40-
setTimeout(() =&gt; {
41-
console.log(result); // Output
42-
}, cancelTimeMs + 50)
27+
const cancelFn = cancellable((x) =&gt; x * 2, [4], 35);
28+
setTimeout(cancelFn, cancelTimeMs);
4329

4430
Every 35ms, fn(4) is called. Until t=190ms, then it is cancelled.
4531
1st fn call is at 0ms. fn(4) returns 8.
@@ -65,7 +51,9 @@ Cancelled at 190ms
6551
{&quot;time&quot;: 150, &quot;returned&quot;: 10}
6652
]
6753
<strong>Explanation:</strong>
68-
const cancelTimeMs = 165;
54+
const cancelTimeMs = 165;
55+
const cancelFn = cancellable((x1, x2) =&gt; (x1 * x2), [2, 5], 30)
56+
setTimeout(cancelFn, cancelTimeMs)
6957

7058
Every 30ms, fn(2, 5) is called. Until t=165ms, then it is cancelled.
7159
1st fn call is at 0ms&nbsp;
@@ -90,6 +78,8 @@ Cancelled at 165ms
9078
]
9179
<strong>Explanation:</strong>
9280
const cancelTimeMs = 180;
81+
const cancelFn = cancellable((x1, x2, x3) =&gt; (x1 + x2 + x3), [5, 1, 3], 50)
82+
setTimeout(cancelFn, cancelTimeMs)
9383

9484
Every 50ms, fn(5, 1, 3) is called. Until t=180ms, then it is cancelled.
9585
1st fn call is at 0ms

solution/2700-2799/2754.Bind Function to Context/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ boundFunc(); // &quot;My name is Kathy&quot;
6868
<p><strong>Constraints:</strong></p>
6969

7070
<ul>
71-
<li><code>obj is a non-null object</code></li>
71+
<li><code>obj</code> is a non-null object</li>
7272
<li><code>0 &lt;= inputs.length &lt;= 100</code></li>
7373
</ul>
7474

solution/2700-2799/2756.Query Batching/README_EN.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
<p><img alt="Throttle info" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2700-2799/2756.Query%20Batching/images/throttle.png" style="width: 622px; height: 200px;" /></p>
2525

26-
<p>&nbsp;</p>
27-
2826
<p>&nbsp;</p>
2927
<p><strong class="example">Example 1:</strong></p>
3028

@@ -119,7 +117,7 @@ queryMultiple([&#39;f&#39;]) is called at t=350ms, it is resolved at 450ms
119117
<li><code>0 &lt;= t &lt;= 1000</code></li>
120118
<li><code>0 &lt;= calls.length &lt;= 10</code></li>
121119
<li><code>1 &lt;= key.length&nbsp;&lt;= 100</code></li>
122-
<li><code>all keys are unique</code></li>
120+
<li>All keys are unique</li>
123121
</ul>
124122

125123
## Solutions

0 commit comments

Comments
 (0)