← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are given n tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTime_i, processingTime_i] means that the i^th task will be available to process at enqueueTime_i and will take processingTime_i to finish.
You have a single-threaded CPU that can process at most one task at a time and will act in the following way:
CPU starts at t=1 with task 0 (length 2). At t=3, tasks 1 and 2 are ready — task 2 wins (length 2 vs 4). At t=5 only task 3 remains and runs (length 1). At t=6 task 1 runs (length 4).
All tasks arrive at t=7; the CPU drains them by shortest processing time, breaking ties by index.