Solution: Single-Threaded CPU
C# solution for the Single-Threaded CPU problem using the Heaps pattern.
We'll cover the following...
Statement
You are given a list tasks of length n, where each tasks[i] = [enqueueTime_i, processingTime_i] describes a single task. Task i becomes available to run at time enqueueTime_i and requires processingTime_i units of CPU time to complete.
A single threaded CPU can run at most one task at a time. When the CPU becomes idle, it must choose one available task to execute using the following rules:
Select the available task with the smallest
processingTime_i.If multiple available tasks have the same
processingTime_i, select the one with the smallest indexi.
Once the CPU starts a task, it runs it to completion without preemption. If no tasks are available, the CPU remains idle until the next task becomes available.
Return an array containing the indices of the tasks in the exact order they are processed by the CPU.
Constraints:
tasks.length == nn...