Processing Tasks

Image placeholder

(This question has been seen in the interviews of the following companies: Tiktok)
Tiktok Online Assessment Questions 2023

Processing tasks

There is a task recorded in the two-dimensional array tasks in the format [start, end, period], indicating that the task needs to be completed within the time range start to end, and period indicates the length of time required to complete the task. Note:
1, The period can be discontinuous time.
2, The start and end are included.
3, The computer can handle an unlimited number of tasks at the same time. 
Please calculate the minimum time that the computer can process all the tasks.

Example:
Input: tasks = [[1,3,2], [2,5,3], [5,6,2]]
Output: 4

Explanation:
tasks[0] selects time points 2, 3.
tasks[1] selects time points 2, 3, 5.
tasks[2] selects time points 5, 6.
So the computer only needs to be on at time points 2, 3, 5 and 6 to complete the task.




Get one-to-one training from Google Facebook engineers

Top-notch Professionals

Learn from Facebook and Google senior engineers interviewed 100+ candidates.
Most recent interview questions and system design topics gathered from aonecode alumnus.
One-to-one online classes. Get feedbacks from real interviewers.

Customized Private Class

Already a coding expert? - Advance straight to hard interview topics of your interest.
New to the ground? - Develop basic coding skills with your own designated mentor.
Days before interview? - Focus on most important problems in target company question bank.