Top-K Ads from Log + Sliding-Window Ingest

Asked at Pinterest · Coding Questions · Difficulty: Medium · Last asked Dec 10, 2025

Two-part ads round: (1) given a static impression log, return the top-K advertisers by impression count; (2) extend to a streaming `ingestImpressions` that scores the top-K within a sliding time window. The streaming follow-up is the scored portion.

Loading the problem…