Algorithm · JPMorgan · Hard
You are asked to design a component that reports the $$k$$ most frequently occurring values inside a very large corpus of items, where the caller supplies k. Begin with the single-node version: tally occurrences into a frequency table, then keep a min-heap of capacity $$k$$ so the number of retained candidates never grows beyond $$k$$. After that, extend the design to a corpus that cannot be held or processed on one machine — partition incoming records by value so that every…
Checking your access…