Minimum Time to Complete All Tasks

Problem There are n tasks; each must run for a given duration somewhere within its inclusive [start, end] time window. Multiple tasks may run during the same second (shared CPU time counts once). Find the minimum total number of seconds the CPU must be powered on to complete every task.

Input / Output

  • Input: n tasks, each as [start, end, duration].
  • Output: the minimum number of seconds the CPU is on.

Constraints

  • Windows are inclusive; overlapping tasks can share powered-on seconds.

Example

  • tasks = [[2,3,1],[4,5,1],[1,5,2]] → 2 (power on second 2 and second 5, reused across tasks).
asked …
LeaderboardSalaryAccount