Streaming top-K frequent elements with O(1) updates

0
Remix

Elements arrive one at a time from an unbounded stream. Design a structure that can report, at any moment, the K elements seen most often so far. Clarify what K is and whether it changes, then avoid a heap: keep frequency buckets in a doubly linked list with a map from element to its bucket, so each update costs O(1) and reading the top K costs O(K). State the cost of every operation.

NvidiaCodingLast asked Sep 2026
No answer yet. Write the first one; the best answer gets endorsed.