Skip to content

Commit 61b2430

Browse files
authored
feat: update lc problems and solutions (#1055)
1 parent ce85b9a commit 61b2430

File tree

29 files changed

+306
-120
lines changed

29 files changed

+306
-120
lines changed

.prettierignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ node_modules/
1616
/solution/0100-0199/0177.Nth Highest Salary/Solution.sql
1717
/solution/1000-1099/1076.Project Employees II/Solution.sql
1818
/solution/1000-1099/1082.Sales Analysis I/Solution.sql
19+
/solution/1100-1199/1173.Immediate Food Delivery I/Solution.sql
20+
/solution/1400-1499/1454.Active Users/Solution.sql
21+
/solution/1400-1499/1484.Group Sold Products By The Date/Solution.sql
1922
/solution/1500-1599/1511.Customer Order Frequency
20-
/solution/1700-1799/1767.Find the Subtasks That Did Not Execute/Solution.sql
2123
/solution/1600-1699/1613.Find the Missing IDs/Solution.sql
22-
/solution/1400-1499/1484.Group Sold Products By The Date/Solution.sql
23-
/solution/1100-1199/1173.Immediate Food Delivery I/Solution.sql
24+
/solution/1700-1799/1767.Find the Subtasks That Did Not Execute/Solution.sql

solution/1000-1099/1034.Coloring A Border/README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88

99
<p>给你一个大小为 <code>m x n</code> 的整数矩阵 <code>grid</code> ,表示一个网格。另给你三个整数&nbsp;<code>row</code>、<code>col</code> 和 <code>color</code> 。网格中的每个值表示该位置处的网格块的颜色。</p>
1010

11-
<p>两个网格块属于同一 <strong>连通分量</strong> 需满足下述全部条件:</p>
11+
<p>如果两个方块在任意 4 个方向上相邻,则称它们&nbsp;<strong>相邻 </strong></p>
1212

13-
<ul>
14-
<li>两个网格块颜色相同</li>
15-
<li>在上、下、左、右任意一个方向上相邻</li>
16-
</ul>
13+
<p>如果两个方块具有相同的颜色且相邻,它们则属于同一个 <strong>连通分量</strong> 。</p>
1714

1815
<p><strong>连通分量的边界</strong><strong> </strong>是指连通分量中满足下述条件之一的所有网格块:</p>
1916

@@ -22,23 +19,25 @@
2219
<li>在网格的边界上(第一行/列或最后一行/列)</li>
2320
</ul>
2421

25-
<p>请你使用指定颜色&nbsp;<code>color</code> 为所有包含网格块&nbsp;<code>grid[row][col]</code> 的 <strong>连通分量的边界</strong> 进行着色,并返回最终的网格&nbsp;<code>grid</code> 。</p>
22+
<p>请你使用指定颜色&nbsp;<code>color</code> 为所有包含网格块&nbsp;<code>grid[row][col]</code> 的 <strong>连通分量的边界</strong> 进行着色。</p>
23+
24+
<p>并返回最终的网格&nbsp;<code>grid</code> 。</p>
2625

2726
<p>&nbsp;</p>
2827

29-
<p><strong>示例 1:</strong></p>
28+
<p><strong class="example">示例 1:</strong></p>
3029

3130
<pre>
3231
<strong>输入:</strong>grid = [[1,1],[1,2]], row = 0, col = 0, color = 3
3332
<strong>输出:</strong>[[3,3],[3,2]]</pre>
3433

35-
<p><strong>示例 2:</strong></p>
34+
<p><strong class="example">示例 2:</strong></p>
3635

3736
<pre>
3837
<strong>输入:</strong>grid = [[1,2,2],[2,3,2]], row = 0, col = 1, color = 3
3938
<strong>输出:</strong>[[1,3,3],[2,3,3]]</pre>
4039

41-
<p><strong>示例 3:</strong></p>
40+
<p><strong class="example">示例 3:</strong></p>
4241

4342
<pre>
4443
<strong>输入:</strong>grid = [[1,1,1],[1,1,1],[1,1,1]], row = 1, col = 1, color = 2
@@ -57,8 +56,6 @@
5756
<li><code>0 &lt;= col &lt; n</code></li>
5857
</ul>
5958

60-
<p>&nbsp;</p>
61-
6259
## 解法
6360

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

solution/1200-1299/1211.Queries Quality and Percentage/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@ Cat 查询结果的劣质查询百分比为 (1 / 3) * 100 = 33.33
8080
### **SQL**
8181

8282
```sql
83-
83+
# Write your MySQL query statement below
84+
SELECT
85+
query_name,
86+
ROUND(AVG(rating / position), 2) AS quality,
87+
ROUND(100 * AVG(rating < 3), 2) AS poor_query_percentage
88+
FROM Queries
89+
GROUP BY query_name;
8490
```
8591

8692
<!-- tabs:end -->

solution/1200-1299/1211.Queries Quality and Percentage/README_EN.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ Cat queries poor_ query_percentage is (1 / 3) * 100 = 33.33
8181
### **SQL**
8282

8383
```sql
84-
84+
# Write your MySQL query statement below
85+
SELECT
86+
query_name,
87+
ROUND(AVG(rating / position), 2) AS quality,
88+
ROUND(100 * AVG(rating < 3), 2) AS poor_query_percentage
89+
FROM Queries
90+
GROUP BY query_name;
8591
```
8692

8793
<!-- tabs:end -->
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Write your MySQL query statement below
2+
SELECT
3+
query_name,
4+
ROUND(AVG(rating / position), 2) AS quality,
5+
ROUND(100 * AVG(rating < 3), 2) AS poor_query_percentage
6+
FROM Queries
7+
GROUP BY query_name;

solution/1200-1299/1232.Check If It Is a Straight Line/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<p>&nbsp;</p>
1212

13-
<p><strong>示例 1:</strong></p>
13+
<p><strong class="example">示例 1:</strong></p>
1414

1515
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1200-1299/1232.Check%20If%20It%20Is%20a%20Straight%20Line/images/untitled-diagram-2.jpg" /></p>
1616

@@ -19,7 +19,7 @@
1919
<strong>输出:</strong>true
2020
</pre>
2121

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

2424
<p><strong><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1200-1299/1232.Check%20If%20It%20Is%20a%20Straight%20Line/images/untitled-diagram-1.jpg" /></strong></p>
2525

solution/1300-1399/1321.Restaurant Growth/README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,29 @@ Customer 表:
7979
### **SQL**
8080

8181
```sql
82-
82+
# Write your MySQL query statement below
83+
WITH
84+
t AS (
85+
SELECT
86+
visited_on,
87+
sum(amount) OVER (
88+
ORDER BY visited_on
89+
ROWS 6 PRECEDING
90+
) AS amount,
91+
rank() OVER (
92+
ORDER BY visited_on
93+
ROWS 6 PRECEDING
94+
) AS rk
95+
FROM
96+
(
97+
SELECT visited_on, sum(amount) AS amount
98+
FROM Customer
99+
GROUP BY visited_on
100+
) AS tt
101+
)
102+
SELECT visited_on, amount, round(amount / 7, 2) AS average_amount
103+
FROM t
104+
WHERE rk > 6;
83105
```
84106

85107
<!-- tabs:end -->

solution/1300-1399/1321.Restaurant Growth/README_EN.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,29 @@ Customer table:
7575
### **SQL**
7676

7777
```sql
78-
78+
# Write your MySQL query statement below
79+
WITH
80+
t AS (
81+
SELECT
82+
visited_on,
83+
sum(amount) OVER (
84+
ORDER BY visited_on
85+
ROWS 6 PRECEDING
86+
) AS amount,
87+
rank() OVER (
88+
ORDER BY visited_on
89+
ROWS 6 PRECEDING
90+
) AS rk
91+
FROM
92+
(
93+
SELECT visited_on, sum(amount) AS amount
94+
FROM Customer
95+
GROUP BY visited_on
96+
) AS tt
97+
)
98+
SELECT visited_on, amount, round(amount / 7, 2) AS average_amount
99+
FROM t
100+
WHERE rk > 6;
79101
```
80102

81103
<!-- tabs:end -->
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Write your MySQL query statement below
2+
WITH
3+
t AS (
4+
SELECT
5+
visited_on,
6+
sum(amount) OVER (
7+
ORDER BY visited_on
8+
ROWS 6 PRECEDING
9+
) AS amount,
10+
rank() OVER (
11+
ORDER BY visited_on
12+
ROWS 6 PRECEDING
13+
) AS rk
14+
FROM
15+
(
16+
SELECT visited_on, sum(amount) AS amount
17+
FROM Customer
18+
GROUP BY visited_on
19+
) AS tt
20+
)
21+
SELECT visited_on, amount, round(amount / 7, 2) AS average_amount
22+
FROM t
23+
WHERE rk > 6;

solution/1400-1499/1454.Active Users/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,19 @@ id = 7 的用户 Jonathon 在不同的 6 天内登录了 7 次, , 6 天中有 5
9292
### **SQL**
9393

9494
```sql
95-
95+
# Write your MySQL query statement below
96+
WITH t AS
97+
(SELECT *,
98+
sum(id) over(partition by id
99+
ORDER BY login_date range interval 4 day preceding)/id cnt
100+
FROM
101+
(SELECT DISTINCT *
102+
FROM Accounts
103+
JOIN Logins using(id) ) tt )
104+
SELECT DISTINCT id,
105+
name
106+
FROM t
107+
WHERE cnt=5;
96108
```
97109

98110
<!-- tabs:end -->

0 commit comments

Comments
 (0)