Kth Largest Stream:Keep k Winners, Peek the Floor
A size-k min-heap peeks the kth largest after each add. Sorting the whole stream on every arrival is honest; a max-heap of every number ranks losers you will never return.
Read More11 questions
A size-k min-heap peeks the kth largest after each add. Sorting the whole stream on every arrival is honest; a max-heap of every number ranks losers you will never return.
Read MoreA max-heap always yields the two heaviest. Sorting after every smash is honest; a min-heap by accident smashes the two lightest.
Read MoreEach user’s tweets are an append-only list; a max-heap of those tails is merge-k. Collect-and-sort is honest; BFS on the follow graph is the wrong shape.
Read MoreA size-k max-heap on squared distance polls the farthest of the current winners. Sorting every pin ranks depots you will never dispatch.
Read MoreEach nums1 index against nums2 is a sorted list of pair sums. A min-heap of those heads is merge-k; expanding both neighbors from (0, 0) needs a seen-set that one-axis seed avoids.
Read MoreA size-k min-heap peeks the kth largest of a frozen array. Sorting descending is honest; ranking every loser you throw away is the extra bill.
Read MoreA min-heap of current heads plus dummy-tail splice rewires k sorted lists in place. Dumping values and sorting rebuilds a new chain; pairwise two-list merge is the heap-free alternative.
Read MoreA max-heap of remaining counts plus a one-slot hold beats trying rearrangements. Idle is failure here — if the only leftover is the letter you just placed, return empty.
Read MoreA max-heap of remaining counts plus a cooldown queue beats rescanning leftovers each slot. The idle-gap formula is the follow-up, not the board default when they said heap.
Read MoreUnlike numeric Top K, the k words must come back frequency-desc then lex-asc. A size-k min-heap evicts the quietest, or the later dictionary word on a tie; drain then reverse.
Read MoreRepresentation and operations — not the problem set.