FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
LeetCode-Solutions/MySQL/find-interview-candidates.sql at master · hackto-dev/LeetCode-Solutions · GitHub
hackto-dev
/
LeetCode-Solutions
Public
forked from
kamyu104/LeetCode-Solutions
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
LeetCode-Solutions
/
MySQL
/
find-interview-candidates.sql
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (29 loc) · 820 Bytes
Breadcrumbs
LeetCode-Solutions
/
MySQL
/
find-interview-candidates.sql
Copy path
File metadata and controls
31 lines (29 loc) · 820 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#
Time: O(nlogn)
#
Space: O(n)
WITH winners_cte
AS
((
SELECT
gold_medal
AS
winner, contest_id
FROM
contests)
UNION ALL
(
SELECT
silver_medal
AS
winner, contest_id
FROM
contests)
UNION ALL
(
SELECT
bronze_medal
AS
winner, contest_id
FROM
contests)),
consecutive_winners_cte
AS
(
SELECT
winner, contest_id, row_number() over(PARTITION BY winner
ORDER BY
contest_id)
AS
row_num
FROM
winners_cte),
candidates_cte
AS
((
SELECT
winner
AS
user_id
FROM
consecutive_winners_cte
GROUP BY
winner, contest_id
-
row_num
HAVING
count
(
1
)
>=
3
ORDER BY
NULL
)
UNION
(
SELECT
gold_medal
AS
user_id
FROM
contests
GROUP BY
gold_medal
HAVING
count
(
1
)
>=
3
ORDER BY
NULL
))
SELECT
u
.
name
,
u
.
mail
FROM
users u
INNER JOIN
candidates_cte c
ON
u
.
user_id
=
c
.
user_id
;
Back
|
FazBrowse Home
|
New Git URL