Skip to content

Commit c5fbc01

Browse files
committed
feat: add sql solution to lc problem: No.0608
1 parent 0a734a0 commit c5fbc01

File tree

5 files changed

+38
-6
lines changed

5 files changed

+38
-6
lines changed

solution/0600-0699/0608.Tree Node/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,22 @@ SELECT id,
9494
FROM tree;
9595
```
9696

97+
```sql
98+
# Write your MySQL query statement below
99+
select
100+
id,
101+
case
102+
when p_id is null then 'Root'
103+
when id in (
104+
select
105+
p_id
106+
from
107+
tree
108+
) then 'Inner'
109+
else 'Leaf'
110+
end Type
111+
from
112+
tree;
113+
```
114+
97115
<!-- tabs:end -->

solution/0600-0699/0608.Tree Node/README_EN.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,22 @@ SELECT id,
105105
FROM tree;
106106
```
107107

108+
```sql
109+
# Write your MySQL query statement below
110+
select
111+
id,
112+
case
113+
when p_id is null then 'Root'
114+
when id in (
115+
select
116+
p_id
117+
from
118+
tree
119+
) then 'Inner'
120+
else 'Leaf'
121+
end Type
122+
from
123+
tree;
124+
```
125+
108126
<!-- tabs:end -->

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252

5353
**方法一:模拟**
5454

55-
将矩阵 `grid` 的每一行以及每一列进行比较,如果相等,那么就是一对相等行列对,答案加一。
55+
我们直接将矩阵 $grid$ 的每一行和每一列进行比较,如果相等,那么就是一对相等行列对,答案加一。
5656

57-
时间复杂度 $O(n^3)$,空间复杂度 $O(1)$。其中 $n$ 为矩阵 `grid` 的行数或列数。
57+
时间复杂度 $O(n^3)$,空间复杂度 $O(1)$。其中 $n$ 为矩阵 $grid$ 的行数或列数。
5858

5959
<!-- tabs:start -->
6060

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
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-
2120
<ul>
2221
<li><code>foods[i]</code> 是第 <code>i</code> 种食物的名字。</li>
2322
<li><code>cuisines[i]</code> 是第 <code>i</code> 种食物的烹饪方式。</li>
@@ -26,7 +25,6 @@
2625
</li>
2726
<li><code>void changeRating(String food, int newRating)</code> 修改名字为 <code>food</code> 的食物的评分。</li>
2827
<li><code>String highestRated(String cuisine)</code> 返回指定烹饪方式 <code>cuisine</code> 下评分最高的食物的名字。如果存在并列,返回 <strong>字典序较小</strong> 的名字。</li>
29-
3028
</ul>
3129

3230
<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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
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-
1918
<ul>
2019
<li><code>foods[i]</code> is the name of the <code>i<sup>th</sup></code> food,</li>
2120
<li><code>cuisines[i]</code> is the type of cuisine of the <code>i<sup>th</sup></code> food, and</li>
@@ -24,7 +23,6 @@
2423
</li>
2524
<li><code>void changeRating(String food, int newRating)</code> Changes the rating of the food item with the name <code>food</code>.</li>
2625
<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>
27-
2826
</ul>
2927

3028
<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>

0 commit comments

Comments
 (0)