ProdMatch
CompaniesCitiesRolesSign in

Companies

  • Google
  • Microsoft
  • Meta
  • Amazon
  • Apple
  • Atlassian
  • Nvidia
  • Oracle
  • See all 51 →

Cities

  • Bengaluru jobs
  • Hyderabad jobs
  • Pune jobs
  • Gurugram jobs
  • Noida jobs
  • Delhi NCR jobs
  • Mumbai jobs
  • Chennai jobs
  • Remote-India jobs

Roles

  • QA / SDET Engineers
  • Backend Engineers
  • Frontend Engineers
  • Full-stack Engineers
  • Data Analysts
  • Data Engineers
  • ML / AI Engineers
  • DevOps / SRE Engineers
  • All roles →

ProdMatch

  • About
  • Career guides
  • Compare
  • Salaries
  • Skills
  • DSA practice
  • Privacy
  • Terms
  • Sign in

© 2026 ProdMatch.ai · Built for India · DPDP Act 2023 compliant · Job data sourced from official company career pages.

Back to DSA
Heap / Priority Queuehard70 minData Engineer

Metrics Real-Time Top-K Prioritizer

Data Engineer signal: heap + top-k in a metric dependency graph context. This is a ProdMatch-owned data engineer drill, framed as a April 2026 Unacademy Analytics Platform simulation, not a copied platform question.

Company context

Unacademy · Analytics Platform

Freshness

April 2026

Product surface

metric dependency graph

ProdMatch interview simulation based on product-team patterns; not a claim of a real company question.

Question

Your Analytics Platform team needs a live top-k view for metrics. Each update changes an item's score. Return the current top k item IDs after each update, ordered by score desc then ID asc.

Input

  • Initial scores, k, and update stream [id, delta].

Output

  • Top-k IDs after every update.

Constraints

  • 1 <= items <= 200000
  • 1 <= updates <= 200000
  • Scores can be negative.

Concepts

  • stream windows
  • watermarks
  • lineage DAGs
  • heap
  • top-k
  • streaming rank

scores: [5,1,3], k=2, update [1,+5] -> [1,0]

Approach

Try framing your own approach first. The 30 seconds you think before peeking is where learning happens.

Clean Solution

Reveal the approach first.

How well did you understand?

Your rating tunes when this problem shows up again.

Common Mistakes

  • Use a stable tie-breaker for equal scores.
  • Do not sort the full stream when k is small.

Next Similar Problems

Watermark Real-Time Top-K PrioritizerhardLineage Real-Time Top-K PrioritizerhardDedupe Real-Time Top-K Prioritizerhard