Loading...
You are given an array tasks, where tasks[i] = [duration, deadline].
tasks
tasks[i] = [duration, deadline]
You process every task one at a time, in an order you choose, starting at time 0 with no gaps: a task started at time t finishes at time t + duration.
0
t
t + duration
Each task scores deadline - finishTime, positive when it finishes early and negative when it finishes late.
deadline - finishTime
Return the maximum possible total score over all processing orders.
Input: tasks = [[6,10],[8,15],[5,12]] Output: 2 Explanation: Process in ascending duration order (5, 6, 8). Finish times are 5, 11 and 19, scoring (12 - 5) + (10 - 11) + (15 - 19) = 7 - 1 - 4 = 2. No order does better.
Input: tasks = [[4,2]] Output: -2 Explanation: The only task finishes at time 4 against deadline 2, so the total is negative.
tasks.length
tasks[i].length
duration
deadline