101
0/304
Loading content...
You are analyzing an event stream stored in a table named Logs with the schema:
Your task is to find every value that appears in a streak of at least 3 consecutive log entries.
Important definition for this problem:
Return a single-column result named:
Result row order is not important.
This problem must be solved for both:
Logs:
| id | num |
|----|-----|
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 4 | 2 |
| 5 | 1 |
| 6 | 2 |
| 7 | 2 |[
{"ConsecutiveNums":"1"}
]Only value 1 forms a run of at least 3 consecutive rows (ids 1, 2, 3).
Logs:
| id | num |
|----|-----|
| 10 | A |
| 20 | A |
| 30 | A |
| 40 | B |
| 50 | B |
| 60 | B |
| 70 | C |[
{"ConsecutiveNums":"A"},
{"ConsecutiveNums":"B"}
]After sorting by id, both A and B each appear in streaks of length 3.
Logs:
| id | num |
|----|-----|
| 1 | x |
| 2 | y |
| 3 | x |
| 4 | y |
| 5 | z |[]No value appears in three adjacent sorted rows, so the result is empty.
Constraints