Back to problems

Design top-K frequency store for varying workloads

Object-Oriented Programming · Microsoft · Medium

Design an in-memory component that tracks how often each key occurs in an online stream of events. The component must support the following operations: record(key): increase the count for key by 1, inserting key if it is not already tracked. topK(k): return the k keys with the highest counts seen so far. The order among the returned keys does not matter. Assume there can be up to N distinct keys, and operations arrive online as the stream is processed. Describe how you would…

Checking your access…