Loading problem...
A competitive gaming analytics team tracks every player's match outcomes and needs a robust measure of momentum.
Table: Matches
Data guarantees:
Definition: A winning streak is the number of consecutive matches with result = "Win" for one player, uninterrupted by "Draw" or "Lose" rows.
Task: For every player present in Matches, return the longest winning streak. Players who never win must have longest_streak = 0.
Output requirements:
Supported submission environments:
Matches:
| player_id | match_day | result |
|-----------|-------------|--------|
| 1 | 2022-01-17 | Win |
| 1 | 2022-01-18 | Win |
| 1 | 2022-01-25 | Win |
| 1 | 2022-01-31 | Draw |
| 1 | 2022-02-08 | Win |
| 2 | 2022-02-06 | Lose |
| 2 | 2022-02-08 | Lose |
| 3 | 2022-03-30 | Win |[
{"player_id":1,"longest_streak":3},
{"player_id":2,"longest_streak":0},
{"player_id":3,"longest_streak":1}
]Player 1 has a best run of three wins before a draw resets the streak. Player 2 never wins, so the best streak is 0. Player 3 wins once, so the best streak is 1.
Matches:
| player_id | match_day | result |
|-----------|-------------|--------|
| 9 | 2023-04-01 | Win |
| 9 | 2023-04-15 | Win |
| 9 | 2023-05-20 | Win |
| 10 | 2023-07-01 | Draw |
| 10 | 2023-07-02 | Lose |
| 11 | 2023-08-10 | Win |
| 11 | 2023-08-11 | Lose |
| 11 | 2023-08-12 | Win |[
{"player_id":9,"longest_streak":3},
{"player_id":10,"longest_streak":0},
{"player_id":11,"longest_streak":1}
]Large date gaps do not break streaks by themselves. Only non-win outcomes break a winning run.
Matches:
| player_id | match_day | result |
|-----------|-------------|--------|
| 21 | 2024-01-01 | Draw |
| 21 | 2024-01-02 | Win |
| 21 | 2024-01-03 | Win |
| 21 | 2024-01-04 | Lose |
| 21 | 2024-01-05 | Win |
| 22 | 2024-01-10 | Draw |
| 22 | 2024-01-12 | Draw |
| 22 | 2024-01-14 | Lose |[
{"player_id":21,"longest_streak":2},
{"player_id":22,"longest_streak":0}
]Player 21 has runs of lengths 2 and 1, so longest is 2. Player 22 has no wins.
Constraints