Find the order of completion of task such that delay will be minimum | Zoho
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2024-02-21Added By Anonymous
Source: Link
You have given a set of task which needs to be completed. You are given deadlines for the given task (in terms of timing). Each task takes a given time to complete it. You have to find the order of task to be done with minimum delay. The timing starts from 9:00 (24 hrs format to be followed)
T.C :
Task Deadline Time taken to complete the task
A 16:00 5
B 12:00 3
C 13:00 2
Optimal Solution: B->C->A
total delay to complete task B : 9:00+3hrs= 12:00, Deadline for B was 12:00. So no delay.
total delay to complete task C : 12:00+2hrs= 14:00, Deadline for C was 13:00. So 1 hour of delay.
total delay to complete task A : 14:00+5hrs= 19:00, Deadline for A was 16:00. So 3 hours of delay.
So minimum delay will be 4 hours
PS: I was asked to solve this problem, but i came up with brute force solution only (by generating all the possible combinations of tasks and calculate all the delay for every order and find the minimum delay).
Also at that time, this was asked only for 3 tasks, but i wanted to know its general solution.
Can anyone provide me the solution.