Telemetry: Top K Frequent Error Codes
Also known as: Top K Frequent Elements
Netflix Error Dashboard: Critical Alert System You're building Netflix's production monitoring dashboard. Given error codes from the last hour, identify the K most frequent issues to display on the ops team's dashboard. For equal frequencies, show lower error codes first (they're typically more critical). Example: errors = [500,500,500,404,404,200], k=2 → [500, 404]
This one tests whether you can keep a best-so-far structure honest as you go. Interviewers love it because it reveals your priority-based reasoning and your edge-case discipline. The trap is stale entries or unbalanced structures—be clear about what belongs in the heap.
Examples
You write
get_most_critical_errors(nums, k)
Example 1
- Input
- [1,1,1,2,2,3], k=2
- returns
- [1, 2]
Example 2
- Input
- [1], k=1
- returns
- [1]
The pattern behind it
Arrays & Hashing
I reach for it when
- You catch yourself scanning the array again for every element.
- The problem asks about duplicates, pairs, counts or groups.
Say this before you type. Say what the key is and what the value remembers, before you write the loop.
All 127 Arrays & Hashing problemsHeaps
I reach for it when
- You need the k largest or k smallest items.
- You repeatedly take the best remaining item.
Say this before you type. Say what the heap holds, how big it stays, and what sits on top.
All 22 Heaps problems
Meet Coco
Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Sign in free to type with Coco, up to a daily limit. The editor and Run stay open without an account. Anyone can open the editor and run their code.
Each locked part opens in the editor once the part before it passes.
Prep guides that list this problem
Our company tags come from public interview write-ups. None of these is a confirmed question.