Top-K Most Frequent Events
Problem Given a large stream of events, return the k most frequent event types by occurrence count.
Input / Output
- Input: a stream (or array) of event names, integer k.
- Output: the k event names with the highest counts (any order among equals).
Constraints
- The stream may be very large — potentially too large to keep every distinct key comfortably in memory.
- k is small relative to the number of distinct event types.
Example
- events = [a,b,a,c,a,b], k = 2 → [a, b] (counts a:3, b:2, c:1).
added …