Skip to content

Commit 625a3e9

Browse files
committed
feat: update lc problems
1 parent a45c493 commit 625a3e9

File tree

26 files changed

+44
-52
lines changed

26 files changed

+44
-52
lines changed

solution/0100-0199/0179.Largest Number/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public class Comparer: IComparer<string>
128128
{
129129
return Compare(left, right, 0, 0);
130130
}
131-
131+
132132
private int Compare(string left, string right, int lBegin, int rBegin)
133133
{
134134
var len = Math.Min(left.Length - lBegin, right.Length - rBegin);
@@ -139,7 +139,7 @@ public class Comparer: IComparer<string>
139139
return left[lBegin + i] < right[rBegin + i] ? -1 : 1;
140140
}
141141
}
142-
142+
143143
if (left.Length - lBegin == right.Length - rBegin)
144144
{
145145
return 0;
@@ -159,7 +159,7 @@ public class Solution {
159159
public string LargestNumber(int[] nums) {
160160
var sb = new StringBuilder();
161161
var strs = nums.Select(n => n.ToString(CultureInfo.InvariantCulture)).OrderByDescending(s => s, new Comparer());
162-
162+
163163
var nonZeroOccurred = false;
164164
foreach (var str in strs)
165165
{

solution/0100-0199/0179.Largest Number/README_EN.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public class Comparer: IComparer<string>
115115
{
116116
return Compare(left, right, 0, 0);
117117
}
118-
118+
119119
private int Compare(string left, string right, int lBegin, int rBegin)
120120
{
121121
var len = Math.Min(left.Length - lBegin, right.Length - rBegin);
@@ -126,7 +126,7 @@ public class Comparer: IComparer<string>
126126
return left[lBegin + i] < right[rBegin + i] ? -1 : 1;
127127
}
128128
}
129-
129+
130130
if (left.Length - lBegin == right.Length - rBegin)
131131
{
132132
return 0;
@@ -146,7 +146,7 @@ public class Solution {
146146
public string LargestNumber(int[] nums) {
147147
var sb = new StringBuilder();
148148
var strs = nums.Select(n => n.ToString(CultureInfo.InvariantCulture)).OrderByDescending(s => s, new Comparer());
149-
149+
150150
var nonZeroOccurred = false;
151151
foreach (var str in strs)
152152
{

solution/0300-0399/0315.Count of Smaller Numbers After Self/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Description
66

7-
<p>You are given an integer array <code>nums</code> and you have to return a new <code>counts</code> array. The <code>counts</code> array has the property where <code>counts[i]</code> is the number of smaller elements to the right of <code>nums[i]</code>.</p>
7+
<p>Given an integer array <code>nums</code>, return<em> an integer array </em><code>counts</code><em> where </em><code>counts[i]</code><em> is the number of smaller elements to the right of </em><code>nums[i]</code>.</p>
88

99
<p>&nbsp;</p>
1010
<p><strong>Example 1:</strong></p>

solution/0300-0399/0347.Top K Frequent Elements/README_EN.md

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

2020
<ul>
2121
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
22+
<li><code>-10<sup>4</sup> &lt;= nums[i] &lt;= 10<sup>4</sup></code></li>
2223
<li><code>k</code> is in the range <code>[1, the number of unique elements in the array]</code>.</li>
2324
<li>It is <strong>guaranteed</strong> that the answer is <strong>unique</strong>.</li>
2425
</ul>

solution/0500-0599/0593.Valid Square/README.md

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

99
<p>给定2D空间中四个点的坐标&nbsp;<code>p1</code>,&nbsp;<code>p2</code>,&nbsp;<code>p3</code>&nbsp;&nbsp;<code>p4</code>,如果这四个点构成一个正方形,则返回 <code>true</code> 。</p>
1010

11-
<p>点的坐标&nbsp;<code>p<sub>i</sub></code> 表示为 <code>[xi, yi]</code> 。输入 <strong>不是</strong> 按任何顺序给出的。</p>
11+
<p>点的坐标&nbsp;<code>p<sub>i</sub></code> 表示为 <code>[xi, yi]</code> 。 <code>输入没有任何顺序</code> 。</p>
1212

1313
<p>一个 <strong>有效的正方形</strong> 有四条等边和四个等角(90度角)。</p>
1414

solution/0600-0699/0622.Design Circular Queue/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -195,37 +195,37 @@ public:
195195
q = vector<int>(k);
196196
front = size = 0;
197197
}
198-
198+
199199
bool enQueue(int value) {
200200
if (isFull()) return false;
201201
int idx = (front + size) % capacity;
202202
q[idx] = value;
203203
++size;
204204
return true;
205205
}
206-
206+
207207
bool deQueue() {
208208
if (isEmpty()) return false;
209209
front = (front + 1) % capacity;
210210
--size;
211211
return true;
212212
}
213-
213+
214214
int Front() {
215215
if (isEmpty()) return -1;
216216
return q[front];
217217
}
218-
218+
219219
int Rear() {
220220
if (isEmpty()) return -1;
221221
int idx = (front + size - 1) % capacity;
222222
return q[idx];
223223
}
224-
224+
225225
bool isEmpty() {
226226
return size == 0;
227227
}
228-
228+
229229
bool isFull() {
230230
return size == capacity;
231231
}

solution/0600-0699/0622.Design Circular Queue/README_EN.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -194,37 +194,37 @@ public:
194194
q = vector<int>(k);
195195
front = size = 0;
196196
}
197-
197+
198198
bool enQueue(int value) {
199199
if (isFull()) return false;
200200
int idx = (front + size) % capacity;
201201
q[idx] = value;
202202
++size;
203203
return true;
204204
}
205-
205+
206206
bool deQueue() {
207207
if (isEmpty()) return false;
208208
front = (front + 1) % capacity;
209209
--size;
210210
return true;
211211
}
212-
212+
213213
int Front() {
214214
if (isEmpty()) return -1;
215215
return q[front];
216216
}
217-
217+
218218
int Rear() {
219219
if (isEmpty()) return -1;
220220
int idx = (front + size - 1) % capacity;
221221
return q[idx];
222222
}
223-
223+
224224
bool isEmpty() {
225225
return size == 0;
226226
}
227-
227+
228228
bool isFull() {
229229
return size == capacity;
230230
}

solution/0600-0699/0638.Shopping Offers/README_EN.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ You cannot add more items, though only $9 for 2A ,2B and 1C.
3939
<p><strong>Constraints:</strong></p>
4040

4141
<ul>
42-
<li><code>n == price.length</code></li>
43-
<li><code>n == needs.length</code></li>
42+
<li><code>n == price.length == needs.length</code></li>
4443
<li><code>1 &lt;= n &lt;= 6</code></li>
45-
<li><code>0 &lt;= price[i] &lt;= 10</code></li>
46-
<li><code>0 &lt;= needs[i] &lt;= 10</code></li>
44+
<li><code>0 &lt;= price[i], needs[i] &lt;= 10</code></li>
4745
<li><code>1 &lt;= special.length &lt;= 100</code></li>
4846
<li><code>special[i].length == n + 1</code></li>
4947
<li><code>0 &lt;= special[i][j] &lt;= 50</code></li>

solution/0800-0899/0802.Find Eventual Safe States/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ var eventualSafeNodes = function (graph) {
322322
* @param {number[][]} graph
323323
* @return {number[]}
324324
*/
325-
var eventualSafeNodes = function(graph) {
325+
var eventualSafeNodes = function (graph) {
326326
const n = graph.length;
327327
const color = new Array(n).fill(0);
328328
function dfs(i) {

solution/0800-0899/0802.Find Eventual Safe States/Solution.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @param {number[][]} graph
33
* @return {number[]}
44
*/
5-
var eventualSafeNodes = function(graph) {
5+
var eventualSafeNodes = function (graph) {
66
const n = graph.length;
77
const color = new Array(n).fill(0);
88
function dfs(i) {
@@ -25,4 +25,4 @@
2525
}
2626
}
2727
return ans;
28-
};
28+
};

solution/1100-1199/1161.Maximum Level Sum of a Binary Tree/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ BFS 层次遍历,求每一层的节点和,找出节点和最大的层,若
5252

5353
**方法二:DFS**
5454

55-
56-
5755
<!-- tabs:start -->
5856

5957
### **Python3**

solution/1200-1299/1209.Remove All Adjacent Duplicates in String II/README_EN.md

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

99
<p>We repeatedly make <code>k</code> <strong>duplicate removals</strong> on <code>s</code> until we no longer can.</p>
1010

11-
<p>Return the final string after all such duplicate removals have been made. It is guaranteed that the answer is unique.</p>
11+
<p>Return <em>the final string after all such duplicate removals have been made</em>. It is guaranteed that the answer is <strong>unique</strong>.</p>
1212

1313
<p>&nbsp;</p>
1414
<p><strong>Example 1:</strong></p>
@@ -41,7 +41,7 @@ Finally delete &quot;ddd&quot;, get &quot;aa&quot;</pre>
4141
<ul>
4242
<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
4343
<li><code>2 &lt;= k &lt;= 10<sup>4</sup></code></li>
44-
<li><code>s</code> only contains lower case English letters.</li>
44+
<li><code>s</code> only contains lowercase English letters.</li>
4545
</ul>
4646

4747
## Solutions

solution/1500-1599/1579.Remove Max Number of Edges to Keep Graph Fully Traversable/README_EN.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
## Description
66

7-
<p>Alice and Bob have an undirected graph of&nbsp;<code>n</code>&nbsp;nodes&nbsp;and 3 types of edges:</p>
7+
<p>Alice and Bob have an undirected graph of <code>n</code> nodes and three types of edges:</p>
88

99
<ul>
1010
<li>Type 1: Can be traversed by Alice only.</li>
1111
<li>Type 2: Can be traversed by Bob only.</li>
12-
<li>Type 3: Can by traversed by both Alice and Bob.</li>
12+
<li>Type 3: Can be traversed by both Alice and Bob.</li>
1313
</ul>
1414

15-
<p>Given an array&nbsp;<code>edges</code>&nbsp;where&nbsp;<code>edges[i] = [type<sub>i</sub>, u<sub>i</sub>, v<sub>i</sub>]</code>&nbsp;represents a bidirectional edge of type&nbsp;<code>type<sub>i</sub></code>&nbsp;between nodes&nbsp;<code>u<sub>i</sub></code>&nbsp;and&nbsp;<code>v<sub>i</sub></code>, find the maximum number of edges you can remove so that after removing the edges, the graph can still be fully traversed by both Alice and Bob. The graph is fully traversed by Alice and Bob if starting from any node, they can reach all other nodes.</p>
15+
<p>Given an array <code>edges</code> where <code>edges[i] = [type<sub>i</sub>, u<sub>i</sub>, v<sub>i</sub>]</code> represents a bidirectional edge of type <code>type<sub>i</sub></code> between nodes <code>u<sub>i</sub></code> and <code>v<sub>i</sub></code>, find the maximum number of edges you can remove so that after removing the edges, the graph can still be fully traversed by both Alice and Bob. The graph is fully traversed by Alice and Bob if starting from any node, they can reach all other nodes.</p>
1616

17-
<p>Return <em>the maximum number of edges you can remove, or return</em> <code>-1</code> <em>if it&#39;s impossible for the graph to be fully traversed by Alice and Bob.</em></p>
17+
<p>Return <em>the maximum number of edges you can remove, or return</em> <code>-1</code> <em>if Alice and Bob cannot fully traverse the graph.</em></p>
1818

1919
<p>&nbsp;</p>
2020
<p><strong>Example 1:</strong></p>
@@ -52,12 +52,12 @@
5252
<p><strong>Constraints:</strong></p>
5353

5454
<ul>
55-
<li><code>1 &lt;= n &lt;= 10^5</code></li>
56-
<li><code>1 &lt;= edges.length &lt;= min(10^5, 3 * n * (n-1) / 2)</code></li>
55+
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
56+
<li><code>1 &lt;= edges.length &lt;= min(10<sup>5</sup>, 3 * n * (n - 1) / 2)</code></li>
5757
<li><code>edges[i].length == 3</code></li>
58-
<li><code>1 &lt;= edges[i][0] &lt;= 3</code></li>
59-
<li><code>1 &lt;= edges[i][1] &lt; edges[i][2] &lt;= n</code></li>
60-
<li>All tuples&nbsp;<code>(type<sub>i</sub>, u<sub>i</sub>, v<sub>i</sub>)</code>&nbsp;are distinct.</li>
58+
<li><code>1 &lt;= type<sub>i</sub> &lt;= 3</code></li>
59+
<li><code>1 &lt;= u<sub>i</sub> &lt; v<sub>i</sub> &lt;= n</code></li>
60+
<li>All tuples <code>(type<sub>i</sub>, u<sub>i</sub>, v<sub>i</sub>)</code> are distinct.</li>
6161
</ul>
6262

6363
## Solutions

solution/1600-1699/1672.Richest Customer Wealth/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class Solution {
159159
}
160160
}
161161
return max
162-
}
162+
}
163163
}
164164
```
165165

solution/1600-1699/1672.Richest Customer Wealth/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class Solution {
152152
}
153153
}
154154
return max
155-
}
155+
}
156156
}
157157
```
158158

solution/2200-2299/2261.K Divisible Elements Subarrays/README_EN.md

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ Since all subarrays are distinct, the total number of subarrays satisfying all t
4949
<li><code>1 &lt;= k &lt;= nums.length</code></li>
5050
</ul>
5151

52+
<p>&nbsp;</p>
53+
<p><strong>Follow up:</strong></p>
54+
55+
<p>Can you solve this problem in O(n<sup>2</sup>) time complexity?</p>
56+
5257
## Solutions
5358

5459
<!-- tabs:start -->

solution/2300-2399/2356.Number of Unique Subjects Taught by Each Teacher/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ Teacher 2:
6363
- They teach subject 4 in department 1.
6464
</pre>
6565

66-
6766
## 解法
6867

6968
<!-- 这里可写通用的实现逻辑 -->

solution/2300-2399/2356.Number of Unique Subjects Taught by Each Teacher/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ Teacher 2:
6161
- They teach subject 4 in department 1.
6262
</pre>
6363

64-
6564
## Solutions
6665

6766
<!-- tabs:start -->

solution/2300-2399/2357.Make Array Zero by Subtracting Equal Amounts/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
<li><code>0 &lt;= nums[i] &lt;= 100</code></li>
4545
</ul>
4646

47-
4847
## 解法
4948

5049
<!-- 这里可写通用的实现逻辑 -->

solution/2300-2399/2357.Make Array Zero by Subtracting Equal Amounts/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ In the third operation, choose x = 2. Now, nums = [0,0,0,0,0].
4141
<li><code>0 &lt;= nums[i] &lt;= 100</code></li>
4242
</ul>
4343

44-
4544
## Solutions
4645

4746
<!-- tabs:start -->

solution/2300-2399/2358.Maximum Number of Groups Entering a Competition/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
<li><code>1 &lt;= grades[i] &lt;= 10<sup>5</sup></code></li>
4545
</ul>
4646

47-
4847
## 解法
4948

5049
<!-- 这里可写通用的实现逻辑 -->

solution/2300-2399/2358.Maximum Number of Groups Entering a Competition/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ It can be shown that it is not possible to form more than 3 groups.
4242
<li><code>1 &lt;= grades[i] &lt;= 10<sup>5</sup></code></li>
4343
</ul>
4444

45-
4645
## Solutions
4746

4847
<!-- tabs:start -->

solution/2300-2399/2359.Find Closest Node to Given Two Nodes/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
<li><code>0 &lt;= node1, node2 &lt; n</code></li>
5151
</ul>
5252

53-
5453
## 解法
5554

5655
<!-- 这里可写通用的实现逻辑 -->

solution/2300-2399/2359.Find Closest Node to Given Two Nodes/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ The maximum of those two distances is 2. It can be proven that we cannot get a n
4444
<li><code>0 &lt;= node1, node2 &lt; n</code></li>
4545
</ul>
4646

47-
4847
## Solutions
4948

5049
<!-- tabs:start -->

solution/2300-2399/2360.Longest Cycle in a Graph/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
<li><code>edges[i] != i</code></li>
4949
</ul>
5050

51-
5251
## 解法
5352

5453
<!-- 这里可写通用的实现逻辑 -->

solution/2300-2399/2360.Longest Cycle in a Graph/README_EN.md

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ The length of this cycle is 3, so 3 is returned.
4040
<li><code>edges[i] != i</code></li>
4141
</ul>
4242

43-
4443
## Solutions
4544

4645
<!-- tabs:start -->

0 commit comments

Comments
 (0)