java.lang.Object
g2501_2600.s2589_minimum_time_to_complete_all_tasks.Solution

public class Solution extends Object
2589 - Minimum Time to Complete All Tasks.<p>Hard</p> <p>There is a computer that can run an unlimited number of tasks <strong>at the same time</strong>. You are given a 2D integer array <code>tasks</code> where <code>tasks[i] = [start<sub>i</sub>, end<sub>i</sub>, duration<sub>i</sub>]</code> indicates that the <code>i<sup>th</sup></code> task should run for a total of <code>duration<sub>i</sub></code> seconds (not necessarily continuous) within the <strong>inclusive</strong> time range <code>[start<sub>i</sub>, end<sub>i</sub>]</code>.</p> <p>You may turn on the computer only when it needs to run a task. You can also turn it off if it is idle.</p> <p>Return <em>the minimum time during which the computer should be turned on to complete all tasks</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> tasks = [[2,3,1],[4,5,1],[1,5,2]]</p> <p><strong>Output:</strong> 2</p> <p><strong>Explanation:</strong></p> <ul> <li>The first task can be run in the inclusive time range [2, 2].</li> <li>The second task can be run in the inclusive time range [5, 5].</li> <li>The third task can be run in the two inclusive time ranges [2, 2] and [5, 5]. The computer will be on for a total of 2 seconds.</li> </ul> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> tasks = [[1,3,2],[2,5,3],[5,6,2]]</p> <p><strong>Output:</strong> 4</p> <p><strong>Explanation:</strong></p> <ul> <li>The first task can be run in the inclusive time range [2, 3].</li> <li>The second task can be run in the inclusive time ranges [2, 3] and [5, 5].</li> <li>The third task can be run in the two inclusive time range [5, 6].</li> </ul> <p>The computer will be on for a total of 4 seconds.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= tasks.length <= 2000</code></li> <li><code>tasks[i].length == 3</code></li> <li><code>1 <= start<sub>i</sub>, end<sub>i</sub> <= 2000</code></li> <li><code>1 <= duration<sub>i</sub> <= end<sub>i</sub> - start<sub>i</sub> + 1</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • findMinimumTime

      public int findMinimumTime(int[][] tasks)