We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 13e8601 commit de95ca1Copy full SHA for de95ca1
Medium/Minimum Processing Time.java
@@ -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