← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Design a data structure that supports two operations:
processEvent(eventId: str) -> None — increments the count for the given event.getTopK(k: int) -> List[str] — returns the k event IDs with the highest counts, sorted in descending order of count. If two events have the same count, return them in lexicographic order.The structure must be efficient: processEvent should run in O(1) time and getTopK should run in O(m log k) time where m is the number of distinct events seen so far. You may assume that k is always valid (0 ≤ k ≤ number of distinct events).