FastPrepFind Minimum Time
Problems/Find Minimum Time

Find Minimum Time

AlphaSense logoAlphaSense● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names the same task, but it does not include the original wording, examples, or limits. The statement, examples, and limits here are ours.

Our version is about 95% the same as the reported question.

Special thanks: 🌷 A special thank you to a lovely, amazing fren for sharing that this question appeared in an interview on November 9, 2026! ( ˶ˆᗜˆ˵ ) 💚

There are n processes to run. Process i has size processSize[i]. There are m processors, and processor j has capacity capacity[j].

A processor can run a process only if the process size is at most its capacity. Running one process takes 1 second.

A processor may run several processes one after another, but after it finishes a process it must rest for 1 second before it starts the next one. Different processors can work at the same time.

Return the minimum number of seconds needed to run every process, or -1 if some process cannot run on any processor.

Function

findMinimumTime(processSize: int[], capacity: int[]) → int

Examples

Example 1

processSize = [2, 5, 3]capacity = [6, 2, 4]return = 1

Give the process of size 5 to the processor with capacity 6, the process of size 2 to the processor with capacity 2, and the process of size 3 to the processor with capacity 4. All three processors work at the same time, so every process is done after 1 second.

Example 2

processSize = [1, 2, 3, 4, 6]capacity = [4, 7, 4]return = 3

There are five processes and only three processors, so some processor must run at least two processes. That processor runs one process, rests for 1 second, and then runs the other, so it needs 3 seconds.

One plan that finishes in 3 seconds: the first processor (capacity 4) runs sizes 2 and 3, the second processor (capacity 7) runs sizes 1 and 6, and the third processor (capacity 4) runs size 4.

Example 3

processSize = [2, 5, 8]capacity = [6, 7, 4]return = -1

The largest capacity is 7, so no processor can run the process of size 8. The answer is -1.

Example 4

processSize = [3, 3, 3]capacity = [5]return = 5

The only processor must run all three processes. It runs them in seconds 1, 3, and 5 and rests in seconds 2 and 4, so the answer is 5.

Constraints

  • 1 <= processSize.length <= 10^5
  • 1 <= capacity.length <= 10^5
  • 1 <= processSize[i] <= 10^9
  • 1 <= capacity[j] <= 10^9

Similar questions at other companies

  • Find Minimum TimeBlackRock · OABlackRock interview questions
  • Shortest Board Length to Cover HolesMicrosoft · OAMicrosoft interview questions
  • Minimize Maximum Group DifferenceDRW · OADRW interview questions
  • Minimum-Cost Solar Rooftop AllocationDeloitte · OADeloitte interview questions
  • K-Means ClusteringFortinet · OAFortinet interview questions
  • Playlist PartitioningTikTok · OATikTok interview questions
  • Get Minimum Pen Drive SizeAmazon · OA
  • Collect PointsFlexport · OAFlexport interview questions
  • Aggressive CowsPeopleStrong · OAPeopleStrong interview questions
  • Spread Cows Across StallsExpedia · OAExpedia interview questions
See AlphaSense hiring insights
Saved
class Solution {
    public int findMinimumTime(int[] processSize, int[] capacity) {
      // Write your code here.
    }

}
Checking account…