This question evaluates data structure design and algorithmic analysis skills, focusing on frequency tracking, tie-breaking and deletion semantics, and reasoning about time and memory complexity.
Design a data structure that tracks the top-K most frequent keys in a stream. Support operations increment(key), decrement(key), and topK(k) -> list of k keys with highest frequencies. Achieve O(