Skip to content

Commit de95ca1

Browse files
authored
Create Minimum Processing Time.java
1 parent 13e8601 commit de95ca1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Medium/Minimum Processing Time.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
public int minProcessingTime(List<Integer> processorTime, List<Integer> tasks) {
3+
PriorityQueue<Integer> taskQueue = new PriorityQueue<>();
4+
PriorityQueue<Integer> processorQueue = new PriorityQueue<>((a, b) -> b - a);
5+
taskQueue.addAll(tasks);
6+
processorQueue.addAll(processorTime);
7+
int totalTime = Integer.MIN_VALUE;
8+
while (!processorQueue.isEmpty()) {
9+
int startTime = processorQueue.remove();
10+
int currTime = Integer.MIN_VALUE;
11+
for (int i = 0; i < 4; i++) {
12+
currTime = Math.max(currTime, startTime + taskQueue.remove());
13+
}
14+
totalTime = Math.max(totalTime, currTime);
15+
}
16+
return totalTime;
17+
}
18+
}

0 commit comments

Comments
 (0)