We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
*With the first three tasks, the optimal schedule can be:
time 1 : task 2
time 2 : task 1
time 3 : task 3
time 4 : task 1
time 5 : task 3
time 6 : task 3
Task 1 has a deadline 2, and it finishes at time 4. So it exceeds its deadline by 2.
Task 2 has a deadline 1, and it finishes at time 1. So it exceeds its deadline by 0.
Task 3 has a deadline 4, and it finishes at time 6. So it exceeds its deadline by 2.
Thus, the maximum time by which you overshoot a deadline is 2. No schedule can do better than this.*
I percieve it would be best to:
time 1 : task 2
time 2 : task 1
time 3 : task 1
time 4 : task 3
time 5 : task 3
time 6 : task 3
and have output:
1
0
2
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Task Scheduling
You are viewing a single comment's thread. Return to all comments →
The problem statement is missing clearity.
*With the first three tasks, the optimal schedule can be: time 1 : task 2 time 2 : task 1 time 3 : task 3 time 4 : task 1 time 5 : task 3 time 6 : task 3
Task 1 has a deadline 2, and it finishes at time 4. So it exceeds its deadline by 2. Task 2 has a deadline 1, and it finishes at time 1. So it exceeds its deadline by 0. Task 3 has a deadline 4, and it finishes at time 6. So it exceeds its deadline by 2.
Thus, the maximum time by which you overshoot a deadline is 2. No schedule can do better than this.*
I percieve it would be best to: time 1 : task 2 time 2 : task 1 time 3 : task 1 time 4 : task 3 time 5 : task 3 time 6 : task 3
and have output: 1 0 2