Find Minimum Time
Updated
Problem statement
There are n processes to execute. Process i has size processSize[i]. There are m processors, and processor i has capacity capacity[i].
A processor completes a process whose size is at most its capacity in 1 second. It cannot execute a process whose size exceeds its capacity.
A processor may execute multiple processes one after another, but it must pause for 1 second after completing a process before starting its next one. Different processors may work simultaneously.
Return the minimum time needed to execute every process, or -1 if completing all processes is impossible.
Function
findMinimumTime(processSize: int[], capacity: int[]) → intExamples
Example 1
processSize = [2, 5, 3]capacity = [6, 2, 4]return = 1The optimal assignment gives:
- The first processor the second process
- The second processor the first process
- The third processor the third process
All three processors work simultaneously and finish in 1 second.
Example 2
processSize = [1, 2, 3, 4, 6]capacity = [4, 7, 4]return = 3Assign process sizes 2 and 3 to the first processor, sizes 1 and 6 to the second processor, and size 4 to the third processor. Each processor with two processes works for 1 second, pauses for 1 second, and works for 1 more second. Therefore, all processes finish in 3 seconds.
Example 3
processSize = [2, 5, 8]capacity = [6, 7, 4]return = -1No processor has enough capacity for the process of size 8, so completing every process is impossible.
More Rippling interview questions
- Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Dependency-Aware Task SchedulerPHONE SCREEN · Seen Nov 2026
- Delivery Cost Tracker with Effective-Dated RatesPHONE SCREEN · Seen Nov 2026
- Most Segments That Sort the ArrayOA · Seen Nov 2026
- Palindromic Paths to the RootOA · Seen Nov 2026
- Server InvestmentOA · Seen Nov 2026
- Camel CardsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best and Worst Camel Card CompletionsPHONE SCREEN · Seen Nov 2026
- Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Minimum Days to Target EngagementTikTok · OA
- Job ExecutionSnowflake · OA
- Maximizing Difference in Array Elements with Moves 🐹Microsoft · OA
- Job ExecutionAdobe · OA
- Minimum Time to Publish Comic BooksNutanix · OA
- Find Minimum TimeAlphaSense · OA
- Find Minimum TimeBlackRock · OA
- Minimize Maximum Group DifferenceDRW · OA
- Minimum-Cost Solar Rooftop AllocationDeloitte · OA
- K-Means ClusteringFortinet · OA