← 返回 waymo 的题目列表Count Super Streaks From Event Logs (with optional user_id follow-up)
类型:online_judge
You are given an event log. A player is in a streak as long as they keep performing the same event type repeatedly, and the time gap between consecutive actions is not greater than a threshold max_gap.
Each event in events contains:
timestamp (integer)
event_type (string or int)
A streak is a maximal contiguous subsequence such that:
all events have the same event_type; and
for every adjacent pair in the subsequence, timestamp[i] - timestamp[i-1] <= max_gap.
A Super Streak is any streak whose length is >= min_len.
Return the number of Super Streaks in events.
Follow-up: if each event also includes user_id, return the Super Streak count per user (e.g., dict[user_id] = count).
Note: if events are not guaranteed to be time-sorted, sort by time; for the follow-up, group/sort by (user_id, timestamp) before counting.
Example
Input
6 5 3
0 A
3 A
9 A
10 A
12 A
14 A
Output
1