Round 1
Questions: There is a dual core processor with one queue for each core. There are n processes, where the time to complete the (i)th process is denoted by time[i] (0 <= i <= n-1). There is a latch that helps decide which process is completed by which core. Initially, the first core has the latch. Suppose the latch is currently with the (c)th core, where c is either 1 or 2, and the (i)th process needs to be assigned. Then one of the following operations must be performed:
- The (i)th process is assigned to the core c, and the latch is given to the other core.
- The (i)th process is assigned to the other core, and the latch is retained by the core c.
The aim of each core is to have a maximum sum of time of processes with them for better performance. So, while assigning the (i)th, the core with the latch decides the operation to be performed such that the total sum of time of processes assigned to it is maximized after all the processes are assigned.
Return the sum of time taken by the first process and the second process i.e. S1 and S2 in an array.
For example:
time = [10, 21, 10, 21, 10] Output = {41, 31}
Explanation: Optimal assignment from both cores would be: C1 takes time[1], time[2], time[4] => Sum = 41 C2 takes time[0] and time[3] => Sum = 31
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.