Single-Threaded CPU
A medium-tier problem at 46% community acceptance, tagged with Array, Sorting, Heap (Priority Queue). Reported in interviews at DoorDash and 2 others.
Single-Threaded CPU is a medium-difficulty scheduling problem that's shown up at DoorDash, IBM, and Microsoft. You're given tasks with execution times and arrival times, and you need to figure out the order a CPU processes them to minimize total time. The trap is thinking greedy works, it doesn't. You need a heap to track which task runs next, and you need to handle idle time correctly. The acceptance rate sits at 46%, which means nearly half the candidates who attempt it fail. If this problem hits your live assessment and the scheduling logic breaks, StealthCoder surfaces a working solution in seconds, invisible to the proctor.
Companies that ask "Single-Threaded CPU"
Single-Threaded CPU is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.
Get StealthCoderThe algorithm requires sorting tasks by arrival time, then using a min-heap (priority queue) to always pick the shortest remaining task available. The core trick most people miss is handling CPU idle periods. If no task has arrived yet, you can't just run the next task, you need to jump the CPU time forward to when the next task arrives. Common failures include processing tasks out of order, miscalculating finish times, or running tasks that haven't arrived yet. You'll need to track which tasks are available, pop from the heap correctly, and update the CPU timer as you go. The solution involves iterating through sorted tasks, maintaining a priority queue of available tasks, and simulating the CPU execution. If you haven't drilled this pattern before and hit it live, StealthCoder hedges that moment by delivering the heap-based simulation logic before you lose focus.
Pattern tags
You know the problem.
Make sure you actually pass it.
Single-Threaded CPU recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Single-Threaded CPU interview FAQ
Why doesn't greedy (always pick the shortest task) work here?+
Greedy fails because you can only pick tasks that have arrived. If the CPU is idle and the shortest task hasn't arrived yet, you must wait. The problem forces you to respect arrival times, which is why you need a heap to manage availability, not just task duration.
Is this still being asked at big tech companies?+
Yes. DoorDash, IBM, and Microsoft all report asking it. The 46% acceptance rate suggests it's still a real filter in their assessments. It's not a rare problem, it's a standard scheduling simulation that tests heap and simulation skills together.
What's the hardest part of implementing this?+
Handling CPU idle time correctly. When no tasks are available, you jump the CPU timer to the next arrival. Most mistakes happen here, either forgetting to jump, or jumping to the wrong time. After that, the heap logic is straightforward.
How does this relate to sorting and heaps?+
You sort tasks by arrival time once at the start. Then a min-heap (by execution time) manages which available task runs next. The two topics work together, sorting sets up the initial order, the heap maintains the run order.
Can I solve this without a heap?+
Technically yes, but inefficiently. You'd scan all available tasks each iteration to find the shortest. A heap makes it O(n log n). At the assessment level, the heap solution is the expected approach, especially given the problem's classification.
Want the actual problem statement? View "Single-Threaded CPU" on LeetCode →