Skip to content

Commit 31bc918

Browse files
committedJun 4, 2023
feat: add solutions to lc problems: No.1747,1783
* No.1747.Leetflex Banned Accounts * No.1783.Grand Slam Titles
1 parent d4bcdcc commit 31bc918

File tree

6 files changed

+129
-4
lines changed

6 files changed

+129
-4
lines changed
 

Diff for: ‎solution/1700-1799/1747.Leetflex Banned Accounts/README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,15 @@ Account ID 4 --> 该账户从 "2021-02-01 17:00:00" 到 "2021-02-01 17:00:00"
7171
### **SQL**
7272

7373
```sql
74-
74+
# Write your MySQL query statement below
75+
select
76+
distinct a.account_id
77+
from
78+
LogInfo a
79+
join LogInfo b on a.account_id = b.account_id
80+
and a.ip_address != b.ip_address
81+
and a.login between b.login
82+
and b.logout;
7583
```
7684

7785
<!-- tabs:end -->

Diff for: ‎solution/1700-1799/1747.Leetflex Banned Accounts/README_EN.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,15 @@ Account ID 4 --&gt; The account was active from &quot;2021-02-01 17:00:00&quot;
6767
### **SQL**
6868

6969
```sql
70-
70+
# Write your MySQL query statement below
71+
select
72+
distinct a.account_id
73+
from
74+
LogInfo a
75+
join LogInfo b on a.account_id = b.account_id
76+
and a.ip_address != b.ip_address
77+
and a.login between b.login
78+
and b.logout;
7179
```
7280

7381
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Write your MySQL query statement below
2+
select
3+
distinct a.account_id
4+
from
5+
LogInfo a
6+
join LogInfo b on a.account_id = b.account_id
7+
and a.ip_address != b.ip_address
8+
and a.login between b.login
9+
and b.logout;

Diff for: ‎solution/1700-1799/1783.Grand Slam Titles/README.md

+34-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,40 @@ Player 3 (Novak) 没有赢得,因此不包含在结果集中。</pre>
8888
### **SQL**
8989

9090
```sql
91-
91+
# Write your MySQL query statement below
92+
select
93+
player_id,
94+
player_name,
95+
sum(
96+
(
97+
case
98+
when Wimbledon = player_id then 1
99+
else 0
100+
end
101+
) + (
102+
case
103+
when Fr_open = player_id then 1
104+
else 0
105+
end
106+
) + (
107+
case
108+
when US_open = player_id then 1
109+
else 0
110+
end
111+
) + (
112+
case
113+
when Au_open = player_id then 1
114+
else 0
115+
end
116+
)
117+
) grand_slams_count
118+
from
119+
Championships
120+
cross join Players
121+
group by
122+
player_id
123+
having
124+
grand_slams_count > 0;
92125
```
93126

94127
<!-- tabs:end -->

Diff for: ‎solution/1700-1799/1783.Grand Slam Titles/README_EN.md

+34-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,40 @@ Player 3 (Novak) did not win anything, we did not include them in the result tab
8484
### **SQL**
8585

8686
```sql
87-
87+
# Write your MySQL query statement below
88+
select
89+
player_id,
90+
player_name,
91+
sum(
92+
(
93+
case
94+
when Wimbledon = player_id then 1
95+
else 0
96+
end
97+
) + (
98+
case
99+
when Fr_open = player_id then 1
100+
else 0
101+
end
102+
) + (
103+
case
104+
when US_open = player_id then 1
105+
else 0
106+
end
107+
) + (
108+
case
109+
when Au_open = player_id then 1
110+
else 0
111+
end
112+
)
113+
) grand_slams_count
114+
from
115+
Championships
116+
cross join Players
117+
group by
118+
player_id
119+
having
120+
grand_slams_count > 0;
88121
```
89122

90123
<!-- tabs:end -->
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Write your MySQL query statement below
2+
select
3+
player_id,
4+
player_name,
5+
sum(
6+
(
7+
case
8+
when Wimbledon = player_id then 1
9+
else 0
10+
end
11+
) + (
12+
case
13+
when Fr_open = player_id then 1
14+
else 0
15+
end
16+
) + (
17+
case
18+
when US_open = player_id then 1
19+
else 0
20+
end
21+
) + (
22+
case
23+
when Au_open = player_id then 1
24+
else 0
25+
end
26+
)
27+
) grand_slams_count
28+
from
29+
Championships
30+
cross join Players
31+
group by
32+
player_id
33+
having
34+
grand_slams_count > 0;

0 commit comments

Comments
 (0)
Please sign in to comment.