You are given two tables: Contests and Users.
The Contests table contains information about LeetCode contests and their medalists:
contest_id: Unique identifier for each contestgold_medal: User ID of the gold medalistsilver_medal: User ID of the silver medalistbronze_medal: User ID of the bronze medalist
The Users table contains user information:
user_id: Unique identifier for each usermail: User's email addressname: User's name
Task: Find all interview candidates. A user qualifies as an interview candidate if:
- They won any medal in three or more consecutive contests, OR
- They won the gold medal in three or more different contests (not necessarily consecutive)
Return the name and mail of all interview candidates in any order.
Table Schema
| Column Name | Type | Description |
|---|---|---|
contest_id
PK
|
int | Unique contest identifier |
gold_medal
|
int | User ID of gold medalist |
silver_medal
|
int | User ID of silver medalist |
bronze_medal
|
int | User ID of bronze medalist |
| Column Name | Type | Description |
|---|---|---|
user_id
PK
|
int | Unique user identifier |
mail
|
varchar | User's email address |
name
|
varchar | User's name |
Input & Output
| contest_id | gold_medal | silver_medal | bronze_medal |
|---|---|---|---|
| 190 | 1 | 2 | 3 |
| 191 | 1 | 4 | 5 |
| 192 | 1 | 6 | 7 |
| 193 | 8 | 9 | 10 |
| user_id | name | |
|---|---|---|
| 1 | [email protected] | Alice |
| 2 | [email protected] | Bob |
| 8 | [email protected] | Charlie |
| name | |
|---|---|
| Alice | [email protected] |
Alice (user_id=1) won gold medals in 3 consecutive contests (190, 191, 192), qualifying her as an interview candidate. She also meets the consecutive medal requirement by winning any medal in 3+ consecutive contests.
| contest_id | gold_medal | silver_medal | bronze_medal |
|---|---|---|---|
| 190 | 1 | 2 | 3 |
| 192 | 1 | 4 | 5 |
| 195 | 1 | 6 | 7 |
| 200 | 8 | 9 | 10 |
| user_id | name | |
|---|---|---|
| 1 | [email protected] | Alice |
| 8 | [email protected] | Charlie |
| name | |
|---|---|
| Alice | [email protected] |
Alice (user_id=1) won gold medals in 3 different contests (190, 192, 195), qualifying her as an interview candidate based on the gold medal criterion. The contests are not consecutive, but that's not required for gold medal qualification.
| contest_id | gold_medal | silver_medal | bronze_medal |
|---|---|---|---|
| 190 | 1 | 2 | 3 |
| 195 | 4 | 5 | 6 |
| user_id | name | |
|---|---|---|
| 1 | [email protected] | Alice |
| 2 | [email protected] | Bob |
| name |
|---|
No user qualifies as an interview candidate. User 1 won only 1 gold medal (need 3+), and no user won medals in 3+ consecutive contests (only 2 contests total).
Constraints
-
1 ≤ contest_id ≤ 1000 -
1 ≤ gold_medal, silver_medal, bronze_medal ≤ 10^6 -
1 ≤ user_id ≤ 10^6 -
All
contest_idvalues are unique - Consecutive contests have consecutive IDs with no gaps