Task Scheduler
Given tasks array (letters A-Z) and cooling period n Find minimum CPU intervals to complete all tasks Same task must wait at least n intervals before repeating Example: tasks = ["A","A","A","B","B","B"], n = 2 => 8 Sequence: A -> B -> idle -> A -> B -> idle -> A -> B
This one rewards reaching for a priority queue instead of repeatedly sorting or scanning. Interviewers love it because it reveals your priority-based reasoning and your edge-case discipline. Interviewers watch whether you keep your heap in sync as inputs evolve.
Examples
You write
least_interval(tasks: List[str], n: int)
Example 1
- Input
- tasks = ["A","A","A","B","B","B"], n = 2
- returns
- 8
Example 2
- Input
- tasks = ["A","C","A","B","D","B"], n = 1
- returns
- 6
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 problemsGreedy
I reach for it when
- A locally best choice looks safe.
- You sort first, then sweep once.
Say this before you type. Say the greedy choice, then say why swapping it for another choice cannot do better.
All 17 Greedy 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.
Prep guides that list this problem
Our company tags come from public interview write-ups. None of these is a confirmed question.