Maximize Sum of Processed Times
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 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 process, 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.
Complete the function maximizeSumOfProcessedTimes in the editor.
maximizeSumOfProcessedTimes has the following parameter:
int[] time: an array of integers representing the time to complete each process
Returns
int[]: an array of two integers representing the sum of time taken by the first and second process respectively
time = [10, 21, 10, 21, 10] return = [41, 31]
🥝🥝- Minimum Absolute Difference PairsONSITE INTERVIEW · Seen Jun 2026
- Count One Groups by SizeOA · Seen Jul 2025
- Minimum Price With Discount CouponsOA · Seen Jul 2025
- Lexicographically Smallest Task QueueOA · Seen Jul 2025
- Team FormationSeen Apr 2025
- Two-Core Process AssignmentSeen Apr 2025
- Unique Digits in RangeSeen Apr 2025
public int[] maximizeSumOfProcessedTimes(int[] time) {
// write your code here
}