Skip to content

Commit e152696

Browse files
authored
feat: add solutions to weekly contest 412 (doocs#3450)
1 parent b0946c3 commit e152696

File tree

47 files changed

+1803
-76
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1803
-76
lines changed

solution/0600-0699/0626.Exchange Seats/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ tags:
2727
+-------------+---------+
2828
id is the primary key (unique value) column for this table.
2929
Each row of this table indicates the name and the ID of a student.
30-
id is a continuous increment.
30+
The ID sequence always starts from 1 and increments continuously.
3131
</pre>
3232

3333
<p>&nbsp;</p>

solution/0600-0699/0690.Employee Importance/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ public:
172172
};
173173
```
174174
175+
#### Go
176+
175177
```go
176178
/**
177179
* Definition for Employee.

solution/0600-0699/0690.Employee Importance/README_EN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ public:
165165
};
166166
```
167167
168+
#### Go
169+
168170
```go
169171
/**
170172
* Definition for Employee.

solution/1000-1099/1052.Grumpy Bookstore Owner/README_EN.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,38 @@ tags:
1919

2020
<!-- description:start -->
2121

22-
<p>There is a bookstore owner that has a store open for <code>n</code> minutes. Every minute, some number of customers enter the store. You are given an integer array <code>customers</code> of length <code>n</code> where <code>customers[i]</code> is the number of the customer that enters the store at the start of the <code>i<sup>th</sup></code> minute and all those customers leave after the end of that minute.</p>
22+
<p>There is a bookstore owner that has a store open for <code>n</code> minutes. You are given an integer array <code>customers</code> of length <code>n</code> where <code>customers[i]</code> is the number of the customers that enter the store at the start of the <code>i<sup>th</sup></code> minute and all those customers leave after the end of that minute.</p>
2323

24-
<p>On some minutes, the bookstore owner is grumpy. You are given a binary array grumpy where <code>grumpy[i]</code> is <code>1</code> if the bookstore owner is grumpy during the <code>i<sup>th</sup></code> minute, and is <code>0</code> otherwise.</p>
24+
<p>During certain minutes, the bookstore owner is grumpy. You are given a binary array grumpy where <code>grumpy[i]</code> is <code>1</code> if the bookstore owner is grumpy during the <code>i<sup>th</sup></code> minute, and is <code>0</code> otherwise.</p>
2525

26-
<p>When the bookstore owner is grumpy, the customers of that minute are not satisfied, otherwise, they are satisfied.</p>
26+
<p>When the bookstore owner is grumpy, the customers entering during that minute are not <strong>satisfied</strong>. Otherwise, they are satisfied.</p>
2727

28-
<p>The bookstore owner knows a secret technique to keep themselves not grumpy for <code>minutes</code> consecutive minutes, but can only use it once.</p>
28+
<p>The bookstore owner knows a secret technique to remain <strong>not grumpy</strong> for <code>minutes</code> consecutive minutes, but this technique can only be used <strong>once</strong>.</p>
2929

30-
<p>Return <em>the maximum number of customers that can be satisfied throughout the day</em>.</p>
30+
<p>Return the <strong>maximum</strong> number of customers that can be <em>satisfied</em> throughout the day.</p>
3131

3232
<p>&nbsp;</p>
3333
<p><strong class="example">Example 1:</strong></p>
3434

35-
<pre>
36-
<strong>Input:</strong> customers = [1,0,1,2,1,1,7,5], grumpy = [0,1,0,1,0,1,0,1], minutes = 3
37-
<strong>Output:</strong> 16
38-
<strong>Explanation:</strong> The bookstore owner keeps themselves not grumpy for the last 3 minutes.
39-
The maximum number of customers that can be satisfied = 1 + 1 + 1 + 1 + 7 + 5 = 16.
40-
</pre>
35+
<div class="example-block">
36+
<p><strong>Input:</strong> <span class="example-io">customers = [1,0,1,2,1,1,7,5], grumpy = [0,1,0,1,0,1,0,1], minutes = 3</span></p>
37+
38+
<p><strong>Output:</strong> <span class="example-io">16</span></p>
39+
40+
<p><strong>Explanation:</strong></p>
41+
42+
<p>The bookstore owner keeps themselves not grumpy for the last 3 minutes.</p>
43+
44+
<p>The maximum number of customers that can be satisfied = 1 + 1 + 1 + 1 + 7 + 5 = 16.</p>
45+
</div>
4146

4247
<p><strong class="example">Example 2:</strong></p>
4348

44-
<pre>
45-
<strong>Input:</strong> customers = [1], grumpy = [0], minutes = 1
46-
<strong>Output:</strong> 1
47-
</pre>
49+
<div class="example-block">
50+
<p><strong>Input:</strong> <span class="example-io">customers = [1], grumpy = [0], minutes = 1</span></p>
51+
52+
<p><strong>Output:</strong> <span class="example-io">1</span></p>
53+
</div>
4854

4955
<p>&nbsp;</p>
5056
<p><strong>Constraints:</strong></p>

solution/1100-1199/1152.Analyze User Website Visit Pattern/README_EN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ tags:
3636
<li>Also, if the pattern is <code>[&quot;luffy&quot;, &quot;luffy&quot;, &quot;luffy&quot;]</code>, the score is the number of users <code>x</code> such that <code>x</code> visited <code>&quot;luffy&quot;</code> three different times at different timestamps.</li>
3737
</ul>
3838

39-
<p>Return <em>the <strong>pattern</strong> with the largest <strong>score</strong></em>. If there is more than one pattern with the same largest score, return the lexicographically smallest such pattern.</p>
39+
<p>Return the <strong>pattern</strong> with the largest <strong>score</strong>. If there is more than one pattern with the same largest score, return the lexicographically smallest such pattern.</p>
40+
41+
<p>Note that the websites in a pattern <strong>do not</strong> need to be visited <em>contiguously</em>, they only need to be visited in the order they appeared in the pattern.</p>
4042

4143
<p>&nbsp;</p>
4244
<p><strong class="example">Example 1:</strong></p>

solution/1300-1399/1334.Find the City With the Smallest Number of Neighbors at a Threshold Distance/README_EN.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ tags:
2828

2929
<p>&nbsp;</p>
3030
<p><strong class="example">Example 1:</strong></p>
31-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1300-1399/1334.Find%20the%20City%20With%20the%20Smallest%20Number%20of%20Neighbors%20at%20a%20Threshold%20Distance/images/find_the_city_01.png" style="width: 300px; height: 225px;" />
31+
32+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1300-1399/1334.Find%20the%20City%20With%20the%20Smallest%20Number%20of%20Neighbors%20at%20a%20Threshold%20Distance/images/problem1334example1.png" style="width: 300px; height: 224px;" /></p>
33+
3234
<pre>
3335
<strong>Input:</strong> n = 4, edges = [[0,1,3],[1,2,1],[1,3,4],[2,3,1]], distanceThreshold = 4
3436
<strong>Output:</strong> 3
@@ -42,7 +44,9 @@ Cities 0 and 3 have 2 neighboring cities at a distanceThreshold = 4, but we have
4244
</pre>
4345

4446
<p><strong class="example">Example 2:</strong></p>
45-
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1300-1399/1334.Find%20the%20City%20With%20the%20Smallest%20Number%20of%20Neighbors%20at%20a%20Threshold%20Distance/images/find_the_city_02.png" style="width: 300px; height: 225px;" />
47+
48+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1300-1399/1334.Find%20the%20City%20With%20the%20Smallest%20Number%20of%20Neighbors%20at%20a%20Threshold%20Distance/images/problem1334example0.png" style="width: 300px; height: 224px;" /></p>
49+
4650
<pre>
4751
<strong>Input:</strong> n = 5, edges = [[0,1,2],[0,4,8],[1,2,3],[1,4,2],[2,3,1],[3,4,1]], distanceThreshold = 2
4852
<strong>Output:</strong> 0

solution/1300-1399/1341.Movie Rating/README_EN.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ title is the name of the movie.
4141
| name | varchar |
4242
+---------------+---------+
4343
user_id is the primary key (column with unique values) for this table.
44+
The column &#39;name&#39; has unique values.
4445
</pre>
4546

46-
<p>&nbsp;</p>
47-
4847
<p>Table: <code>MovieRating</code></p>
4948

5049
<pre>
@@ -56,7 +55,7 @@ user_id is the primary key (column with unique values) for this table.
5655
| rating | int |
5756
| created_at | date |
5857
+---------------+---------+
59-
(movie_id, user_id) is the primary key (column with unique values)&nbsp;for this table.
58+
(movie_id, user_id) is the primary key (column with unique values) for this table.
6059
This table contains the rating of a movie by a user in their review.
6160
created_at is the user&#39;s review date.
6261
</pre>

solution/1400-1499/1462.Course Schedule IV/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ Course 0 is not a prerequisite of course 1, but the opposite is true.
6565
<li><code>2 &lt;= numCourses &lt;= 100</code></li>
6666
<li><code>0 &lt;= prerequisites.length &lt;= (numCourses * (numCourses - 1) / 2)</code></li>
6767
<li><code>prerequisites[i].length == 2</code></li>
68-
<li><code>0 &lt;= a<sub>i</sub>, b<sub>i</sub> &lt;= n - 1</code></li>
68+
<li><code>0 &lt;= a<sub>i</sub>, b<sub>i</sub> &lt;= numCourses - 1</code></li>
6969
<li><code>a<sub>i</sub> != b<sub>i</sub></code></li>
7070
<li>All the pairs <code>[a<sub>i</sub>, b<sub>i</sub>]</code> are <strong>unique</strong>.</li>
7171
<li>The prerequisites graph has no cycles.</li>
7272
<li><code>1 &lt;= queries.length &lt;= 10<sup>4</sup></code></li>
73-
<li><code>0 &lt;= u<sub>i</sub>, v<sub>i</sub> &lt;= n - 1</code></li>
73+
<li><code>0 &lt;= u<sub>i</sub>, v<sub>i</sub> &lt;= numCourses - 1</code></li>
7474
<li><code>u<sub>i</sub> != v<sub>i</sub></code></li>
7575
</ul>
7676

0 commit comments

Comments
 (0)