Skip to content

Commit c7e5251

Browse files
committed
feat: update lc problems
1 parent 7e373a2 commit c7e5251

File tree

23 files changed

+67
-54
lines changed

23 files changed

+67
-54
lines changed

solution/0000-0099/0015.3Sum/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<strong>Input:</strong> nums = [-1,0,1,2,-1,-4]
1616
<strong>Output:</strong> [[-1,-1,2],[-1,0,1]]
1717
<strong>Explanation:</strong>
18-
nums[0] + nums[1] + nums[1] = (-1) + 0 + 1 = 0.
18+
nums[0] + nums[1] + nums[2] = (-1) + 0 + 1 = 0.
1919
nums[1] + nums[2] + nums[4] = 0 + 1 + (-1) = 0.
2020
nums[0] + nums[3] + nums[4] = (-1) + 2 + (-1) = 0.
2121
The distinct triplets are [-1,0,1] and [-1,-1,2].

solution/0000-0099/0030.Substring with Concatenation of All Words/README_EN.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ The output order does not matter, returning [9,0] is fine too.
3737

3838
<ul>
3939
<li><code>1 &lt;= s.length &lt;= 10<sup>4</sup></code></li>
40-
<li><code>s</code> consists of lower-case English letters.</li>
4140
<li><code>1 &lt;= words.length &lt;= 5000</code></li>
4241
<li><code>1 &lt;= words[i].length &lt;= 30</code></li>
43-
<li><code>words[i]</code>&nbsp;consists of lower-case English letters.</li>
42+
<li><code>s</code> and <code>words[i]</code> consist of lowercase English letters.</li>
4443
</ul>
4544

4645
## Solutions

solution/0200-0299/0215.Kth Largest Element in an Array/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<p><strong>提示: </strong></p>
3131

3232
<ul>
33-
<li><code>1 &lt;= k &lt;= nums.length &lt;= 10<sup>4</sup></code></li>
33+
<li><code>1 &lt;= k &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
3434
<li><code>-10<sup>4</sup>&nbsp;&lt;= nums[i] &lt;= 10<sup>4</sup></code></li>
3535
</ul>
3636

solution/0200-0299/0297.Serialize and Deserialize Binary Tree/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<p>Design an algorithm to serialize and deserialize a binary tree. There is no restriction on how your serialization/deserialization algorithm should work. You just need to ensure that a binary tree can be serialized to a string and this string can be deserialized to the original tree structure.</p>
1010

11-
<p><strong>Clarification:</strong> The input/output format is the same as <a href="/faq/#binary-tree" target="_blank">how LeetCode serializes a binary tree</a>. You do not necessarily need to follow this format, so please be creative and come up with different approaches yourself.</p>
11+
<p><strong>Clarification:</strong> The input/output format is the same as <a href="https://support.leetcode.com/hc/en-us/articles/360011883654-What-does-1-null-2-3-mean-in-binary-tree-representation-" target="_blank">how LeetCode serializes a binary tree</a>. You do not necessarily need to follow this format, so please be creative and come up with different approaches yourself.</p>
1212

1313
<p>&nbsp;</p>
1414
<p><strong>Example 1:</strong></p>

solution/0300-0399/0336.Palindrome Pairs/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
<strong>输出:</strong>[[0,1],[1,0]]
3333
</pre>
3434

35+
36+
3537
<p><strong>提示:</strong></p>
3638

3739
<ul>

solution/0500-0599/0554.Brick Wall/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
<strong>输出:</strong>3
2929
</pre>
3030

31+
32+
3133
<p><strong>提示:</strong></p>
3234

3335
<ul>

solution/0500-0599/0592.Fraction Addition and Subtraction/Solution.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def fractionAddition(self, expression: str) -> str:
1010
j = i
1111
while j < n and expression[j] not in '+-':
1212
j += 1
13-
s = expression[i: j]
13+
s = expression[i:j]
1414
a, b = s.split('/')
1515
x += sign * int(a) * y // int(b)
1616
i = j

solution/0700-0799/0775.Global and Local Inversions/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
<strong>解释:</strong>有 2 个全局倒置,和 1 个局部倒置。
4343
</pre>
4444

45+
46+
4547
<p><strong>提示:</strong></p>
4648

4749
<ul>

solution/0800-0899/0830.Positions of Large Groups/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
<strong>输出:</strong>[]
4949
</pre>
5050

51+
52+
5153
<p><strong>提示:</strong></p>
5254

5355
<ul>

solution/1000-1099/1030.Matrix Cells in Distance Order/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

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

9-
<p>给定四个整数 <code>row</code>&nbsp;,&nbsp; &nbsp;<code>cols</code> ,&nbsp; <code>rCenter</code> 和 <code>cCenter</code> 。有一个&nbsp;<code>rows x cols</code>&nbsp;的矩阵,你在单元格上的坐标是&nbsp;<code>(rCenter, cCenter)</code> 。</p>
9+
<p>给定四个整数 <code>rows</code>&nbsp;,&nbsp; &nbsp;<code>cols</code> ,&nbsp; <code>rCenter</code> 和 <code>cCenter</code> 。有一个&nbsp;<code>rows x cols</code>&nbsp;的矩阵,你在单元格上的坐标是&nbsp;<code>(rCenter, cCenter)</code> 。</p>
1010

1111
<p>返回矩阵中的所有单元格的坐标,并按与<em>&nbsp;</em><code>(rCenter, cCenter)</code><em>&nbsp;</em>的 <strong>距离</strong> 从最小到最大的顺序排。你可以按 <strong>任何</strong> 满足此条件的顺序返回答案。</p>
1212

solution/1100-1199/1146.Snapshot Array/README_EN.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<p>Implement a SnapshotArray that supports the following interface:</p>
88

99
<ul>
10-
<li><code>SnapshotArray(int length)</code> initializes an array-like data structure with the given length.&nbsp; <strong>Initially, each element equals 0</strong>.</li>
10+
<li><code>SnapshotArray(int length)</code> initializes an array-like data structure with the given length. <strong>Initially, each element equals 0</strong>.</li>
1111
<li><code>void set(index, val)</code> sets the element at the given <code>index</code> to be equal to <code>val</code>.</li>
12-
<li><code>int snap()</code>&nbsp;takes a snapshot of the array and returns the <code>snap_id</code>: the total number of times we called <code>snap()</code> minus <code>1</code>.</li>
13-
<li><code>int get(index, snap_id)</code>&nbsp;returns the value at the given <code>index</code>, at the time we took the snapshot with the given <code>snap_id</code></li>
12+
<li><code>int snap()</code> takes a snapshot of the array and returns the <code>snap_id</code>: the total number of times we called <code>snap()</code> minus <code>1</code>.</li>
13+
<li><code>int get(index, snap_id)</code> returns the value at the given <code>index</code>, at the time we took the snapshot with the given <code>snap_id</code></li>
1414
</ul>
1515

1616
<p>&nbsp;</p>
@@ -31,11 +31,11 @@ snapshotArr.get(0,0); // Get the value of array[0] with snap_id = 0, return 5</
3131
<p><strong>Constraints:</strong></p>
3232

3333
<ul>
34-
<li><code>1 &lt;= length&nbsp;&lt;= 50000</code></li>
35-
<li>At most <code>50000</code>&nbsp;calls will be made to <code>set</code>, <code>snap</code>, and <code>get</code>.</li>
36-
<li><code>0 &lt;= index&nbsp;&lt;&nbsp;length</code></li>
37-
<li><code>0 &lt;=&nbsp;snap_id &lt;&nbsp;</code>(the total number of times we call <code>snap()</code>)</li>
38-
<li><code>0 &lt;=&nbsp;val &lt;= 10^9</code></li>
34+
<li><code>1 &lt;= length &lt;= 5 * 10<sup>4</sup></code></li>
35+
<li><code>0 &lt;= index &lt; length</code></li>
36+
<li><code>0 &lt;= val &lt;= 10<sup>9</sup></code></li>
37+
<li><code>0 &lt;= snap_id &lt; </code>(the total number of times we call <code>snap()</code>)</li>
38+
<li>At most <code>5 * 10<sup>4</sup></code> calls will be made to <code>set</code>, <code>snap</code>, and <code>get</code>.</li>
3939
</ul>
4040

4141
## Solutions

solution/1200-1299/1206.Design Skiplist/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public:
356356
head = new Node(-1, maxLevel);
357357
level = 0;
358358
}
359-
359+
360360
bool search(int target) {
361361
Node* curr = head;
362362
for (int i = level - 1; ~i; --i)
@@ -366,7 +366,7 @@ public:
366366
}
367367
return false;
368368
}
369-
369+
370370
void add(int num) {
371371
Node* curr = head;
372372
int lv = randomLevel();
@@ -382,7 +382,7 @@ public:
382382
}
383383
}
384384
}
385-
385+
386386
bool erase(int num) {
387387
Node* curr = head;
388388
bool ok = false;

solution/1200-1299/1206.Design Skiplist/README_EN.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ public:
344344
head = new Node(-1, maxLevel);
345345
level = 0;
346346
}
347-
347+
348348
bool search(int target) {
349349
Node* curr = head;
350350
for (int i = level - 1; ~i; --i)
@@ -354,7 +354,7 @@ public:
354354
}
355355
return false;
356356
}
357-
357+
358358
void add(int num) {
359359
Node* curr = head;
360360
int lv = randomLevel();
@@ -370,7 +370,7 @@ public:
370370
}
371371
}
372372
}
373-
373+
374374
bool erase(int num) {
375375
Node* curr = head;
376376
bool ok = false;
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class Solution:
22
def nthPersonGetsNthSeat(self, n: int) -> float:
3-
return 1 if n == 1 else .5
3+
return 1 if n == 1 else 0.5

solution/1500-1599/1505.Minimum Possible Integer After at Most K Adjacent Swaps On Digits/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<ul>
4040
<li><code>1 &lt;= num.length &lt;= 3 * 10<sup>4</sup></code></li>
4141
<li><code>num</code> consists of only <strong>digits</strong> and does not contain <strong>leading zeros</strong>.</li>
42-
<li><code>1 &lt;= k &lt;= 10<sup>4</sup></code></li>
42+
<li><code>1 &lt;= k &lt;= 10<sup>9</sup></code></li>
4343
</ul>
4444

4545
## Solutions

solution/2300-2399/2332.The Latest Time to Catch a Bus/README_EN.md

+17-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88

99
<p>You are given an integer <code>capacity</code>, which represents the <strong>maximum</strong> number of passengers that can get on each bus.</p>
1010

11-
<p>The passengers will get on the next available bus. You can get on a bus that will depart at <code>x</code> minutes if you arrive at <code>y</code> minutes where <code>y &lt;= x</code>, and the bus is not full. Passengers with the <strong>earliest</strong> arrival times get on the bus first.</p>
11+
<p>When a passenger arrives, they will wait in line for the next available bus. You can get on a bus that departs at <code>x</code> minutes if you arrive at <code>y</code> minutes where <code>y &lt;= x</code>, and the bus is not full. Passengers with the <strong>earliest</strong> arrival times get on the bus first.</p>
12+
13+
<p>More formally when a bus arrives, either:</p>
14+
15+
<ul>
16+
<li>If <code>capacity</code> or fewer passengers are waiting for a bus, they will <strong>all</strong> get on the bus, or</li>
17+
<li>The <code>capacity</code> passengers with the <strong>earliest</strong> arrival times will get on the bus.</li>
18+
</ul>
1219

1320
<p>Return <em>the latest time you may arrive at the bus station to catch a bus</em>. You <strong>cannot</strong> arrive at the same time as another passenger.</p>
1421

@@ -20,21 +27,21 @@
2027
<pre>
2128
<strong>Input:</strong> buses = [10,20], passengers = [2,17,18,19], capacity = 2
2229
<strong>Output:</strong> 16
23-
<strong>Explanation:</strong>
24-
The 1<sup>st</sup> bus departs with the 1<sup>st</sup> passenger.
25-
The 2<sup>nd</sup> bus departs with you and the 2<sup>nd</sup> passenger.
26-
Note that you must not arrive at the same time as the passengers, which is why you must arrive before the 2<sup>nd</sup><sup> </sup>passenger to catch the bus.</pre>
30+
<strong>Explanation:</strong> Suppose you arrive at time 16.
31+
At time 10, the first bus departs with the 0<sup>th</sup> passenger.
32+
At time 20, the second bus departs with you and the 1<sup>st</sup> passenger.
33+
Note that you may not arrive at the same time as another passenger, which is why you must arrive before the 1<sup>st</sup> passenger to catch the bus.</pre>
2734

2835
<p><strong>Example 2:</strong></p>
2936

3037
<pre>
3138
<strong>Input:</strong> buses = [20,30,10], passengers = [19,13,26,4,25,11,21], capacity = 2
3239
<strong>Output:</strong> 20
33-
<strong>Explanation:</strong>
34-
The 1<sup>st</sup> bus departs with the 4<sup>th</sup> passenger.
35-
The 2<sup>nd</sup> bus departs with the 6<sup>th</sup>&nbsp;and 2<sup>nd</sup><sup> </sup>passengers.
36-
The 3<sup>rd</sup> bus departs with the 1<sup>s</sup><sup>t</sup> passenger and you.
37-
</pre>
40+
<strong>Explanation:</strong> Suppose you arrive at time 20.
41+
At time 10, the first bus departs with the 3<sup>rd</sup> passenger.
42+
At time 20, the second bus departs with the 5<sup>th</sup> and 1<sup>st</sup> passengers.
43+
At time 30, the third bus departs with the 0<sup>th</sup> passenger and you.
44+
Notice if you had arrived any later, then the 6<sup>th</sup> passenger would have taken your seat on the third bus.</pre>
3845

3946
<p>&nbsp;</p>
4047
<p><strong>Constraints:</strong></p>

solution/2300-2399/2352.Equal Row and Column Pairs/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<p><strong>示例 1:</strong></p>
1616

17-
<p><img alt="" src="https://assets.leetcode.com/uploads/2022/06/01/ex1.jpg" style="width: 150px; height: 153px;" /></p>
17+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2300-2399/2352.Equal%20Row%20and%20Column%20Pairs/images/ex1.jpg" style="width: 150px; height: 153px;" /></p>
1818

1919
<pre>
2020
<strong>输入:</strong>grid = [[3,2,1],[1,7,6],[2,7,7]]
@@ -25,7 +25,7 @@
2525

2626
<p><strong>示例 2:</strong></p>
2727

28-
<p><img alt="" src="https://assets.leetcode.com/uploads/2022/06/01/ex2.jpg" style="width: 200px; height: 209px;" /></p>
28+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2300-2399/2352.Equal%20Row%20and%20Column%20Pairs/images/ex2.jpg" style="width: 200px; height: 209px;" /></p>
2929

3030
<pre>
3131
<strong>输入:</strong>grid = [[3,1,2,2],[1,4,4,5],[2,4,2,2],[2,4,2,2]]

solution/2300-2399/2352.Equal Row and Column Pairs/README_EN.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<p>&nbsp;</p>
1212
<p><strong>Example 1:</strong></p>
13-
<img alt="" src="https://assets.leetcode.com/uploads/2022/06/01/ex1.jpg" style="width: 150px; height: 153px;" />
13+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2300-2399/2352.Equal%20Row%20and%20Column%20Pairs/images/ex1.jpg" style="width: 150px; height: 153px;" />
1414
<pre>
1515
<strong>Input:</strong> grid = [[3,2,1],[1,7,6],[2,7,7]]
1616
<strong>Output:</strong> 1
@@ -19,7 +19,7 @@
1919
</pre>
2020

2121
<p><strong>Example 2:</strong></p>
22-
<img alt="" src="https://assets.leetcode.com/uploads/2022/06/01/ex2.jpg" style="width: 200px; height: 209px;" />
22+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2300-2399/2352.Equal%20Row%20and%20Column%20Pairs/images/ex2.jpg" style="width: 200px; height: 209px;" />
2323
<pre>
2424
<strong>Input:</strong> grid = [[3,1,2,2],[1,4,4,5],[2,4,2,2],[2,4,2,2]]
2525
<strong>Output:</strong> 3
Loading
Loading

solution/2300-2399/2353.Design a Food Rating System/README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717

1818
<ul>
1919
<li><code>FoodRatings(String[] foods, String[] cuisines, int[] ratings)</code> 初始化系统。食物由 <code>foods</code>、<code>cuisines</code> 和 <code>ratings</code> 描述,长度均为 <code>n</code> 。
20-
<ul>
21-
<li><code>foods[i]</code> 是第 <code>i</code> 种食物的名字。</li>
22-
<li><code>cuisines[i]</code> 是第 <code>i</code> 种食物的烹饪方式。</li>
23-
<li><code>ratings[i]</code> 是第 <code>i</code> 种食物的最初评分。</li>
24-
</ul>
25-
</li>
26-
<li><code>void changeRating(String food, int newRating)</code> 修改名字为 <code>food</code> 的食物的评分。</li>
27-
<li><code>String highestRated(String cuisine)</code> 返回指定烹饪方式 <code>cuisine</code> 下评分最高的食物的名字。如果存在并列,返回 <strong>字典序较小</strong> 的名字。</li>
20+
<ul>
21+
<li><code>foods[i]</code> 是第 <code>i</code> 种食物的名字。</li>
22+
<li><code>cuisines[i]</code> 是第 <code>i</code> 种食物的烹饪方式。</li>
23+
<li><code>ratings[i]</code> 是第 <code>i</code> 种食物的最初评分。</li>
24+
</ul>
25+
</li>
26+
<li><code>void changeRating(String food, int newRating)</code> 修改名字为 <code>food</code> 的食物的评分。</li>
27+
<li><code>String highestRated(String cuisine)</code> 返回指定烹饪方式 <code>cuisine</code> 下评分最高的食物的名字。如果存在并列,返回 <strong>字典序较小</strong> 的名字。</li>
2828
</ul>
2929

3030
<p>注意,字符串 <code>x</code> 的字典序比字符串 <code>y</code> 更小的前提是:<code>x</code> 在字典中出现的位置在 <code>y</code> 之前,也就是说,要么 <code>x</code> 是 <code>y</code> 的前缀,或者在满足&nbsp;<code>x[i] != y[i]</code> 的第一个位置 <code>i</code> 处,<code>x[i]</code> 在字母表中出现的位置在 <code>y[i]</code> 之前。</p>

solution/2300-2399/2353.Design a Food Rating System/README_EN.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515

1616
<ul>
1717
<li><code>FoodRatings(String[] foods, String[] cuisines, int[] ratings)</code> Initializes the system. The food items are described by <code>foods</code>, <code>cuisines</code> and <code>ratings</code>, all of which have a length of <code>n</code>.
18-
<ul>
19-
<li><code>foods[i]</code> is the name of the <code>i<sup>th</sup></code> food,</li>
20-
<li><code>cuisines[i]</code> is the type of cuisine of the <code>i<sup>th</sup></code> food, and</li>
21-
<li><code>ratings[i]</code> is the initial rating of the <code>i<sup>th</sup></code> food.</li>
22-
</ul>
23-
</li>
24-
<li><code>void changeRating(String food, int newRating)</code> Changes the rating of the food item with the name <code>food</code>.</li>
25-
<li><code>String highestRated(String cuisine)</code> Returns the name of the food item that has the highest rating for the given type of <code>cuisine</code>. If there is a tie, return the item with the <strong>lexicographically smaller</strong> name.</li>
18+
<ul>
19+
<li><code>foods[i]</code> is the name of the <code>i<sup>th</sup></code> food,</li>
20+
<li><code>cuisines[i]</code> is the type of cuisine of the <code>i<sup>th</sup></code> food, and</li>
21+
<li><code>ratings[i]</code> is the initial rating of the <code>i<sup>th</sup></code> food.</li>
22+
</ul>
23+
</li>
24+
<li><code>void changeRating(String food, int newRating)</code> Changes the rating of the food item with the name <code>food</code>.</li>
25+
<li><code>String highestRated(String cuisine)</code> Returns the name of the food item that has the highest rating for the given type of <code>cuisine</code>. If there is a tie, return the item with the <strong>lexicographically smaller</strong> name.</li>
2626
</ul>
2727

2828
<p>Note that a string <code>x</code> is lexicographically smaller than string <code>y</code> if <code>x</code> comes before <code>y</code> in dictionary order, that is, either <code>x</code> is a prefix of <code>y</code>, or if <code>i</code> is the first position such that <code>x[i] != y[i]</code>, then <code>x[i]</code> comes before <code>y[i]</code> in alphabetic order.</p>

solution/2300-2399/2355.Maximum Number of Books You Can Take/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ It can be proven that 13 is the maximum number of books you can take.
6060
<li><code>0 &lt;= books[i] &lt;= 10<sup>5</sup></code></li>
6161
</ul>
6262

63-
6463
## Solutions
6564

6665
<!-- tabs:start -->

0 commit comments

Comments
 (0)