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 minAI/ML Engineer

GraphRAG Real-Time Top-K Prioritizer

AI/ML Engineer signal: heap + top-k in a knowledge graph RAG context. This is a ProdMatch-owned ai ml engineer drill, framed as a April 2026 Apple AI Search simulation, not a copied platform question.

Company context

Apple · AI Search

Freshness

April 2026

Product surface

knowledge graph RAG

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

Question

Your AI Search team needs a live top-k view for entities. 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

  • vector search
  • RAG retrieval
  • recommendation graphs
  • 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

Vector Real-Time Top-K PrioritizerhardRecommend Real-Time Top-K PrioritizerhardBatching Real-Time Top-K Prioritizerhard