Job Execution
Updated
Problem statement
There are jobs that can be executed in parallel on a processor, where the execution time of the j^th job is executionTime[j]. To speed up execution, the following strategy is used.
In one operation, a job is chosen, the major job, and is executed for x seconds. All other jobs are executed for y seconds where y < x.
A job is complete when it has been executed for at least executionTime[j] seconds, then it exits the pool. Find the minimum number of operations in which the processor can completely execute all the jobs if run optimally.
Function
AdobeGetMinimumOperations(executionTime: int[], x: int, y: int) → int
Complete the function getMinimumOperations in the editor.
getMinimumOperations has the following parameters:
int executionTime[n]: the execution times of each jobint x: the time for which the major job is executedint y: the time for which all other jobs are executed
Examples
Example 1
executionTime = [3, 4, 1, 7, 6]x = 4y = 2return = 3The following strategy is optimal using 1-based indexing.
- Choose job 4 as the major job and reduce the execution times of job 4 by
x = 4and of other jobs byy = 2. NowexecutionTime = [1, 2, -1, 3, 4]. Job 3 is complete, so it is removed. - Choose job 4,
executionTime = [-1, 0, -, -1, 2]. So, jobs 1, 2, and 4 are now complete. - Choose job 5,
executionTime = [-, -, -, -, -2]. Job 5 is complete.
It takes 3 operations to execute all the jobs so the answer is 3.
Example 2
executionTime = [1,2,3,6,7]x = 4y = 2return = 3The jobs needing 6 and 7 seconds require at least 1 and 2 major selections to finish within two operations. Their total is 3, but only two selections are available. Three operations are enough: choose jobs 5, 4, 5 as major jobs. Before removing jobs that just finished, the remaining-work rows are [-1,0,1,4,3], [-,-,-1,0,1], and [-,-,-,-,-3]. A dash marks a job removed in an earlier operation. The minimum is 3.
Constraints
- For this exercise, assume 1 <= executionTime.length <= 100000.
- For this exercise, assume 1 <= executionTime[i] <= 10^9.
- For this exercise, assume 2 <= x <= 10^9 and 1 <= y <= 10^9.
- The background time y is strictly less than the major-job time x.
More Adobe interview questions
- Base Unit ConversionsOA · Seen Nov 2026
- Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
- All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Top-Funded Villages and ProjectsOA · Seen Aug 2026
- Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
- Lowest Common Ancestor Only When Both Targets ExistONSITE INTERVIEW · Seen Aug 2026
- Lowest Common Ancestor with Parent PointersONSITE INTERVIEW · Seen Aug 2026
- Next and Previous Lexicographic PermutationONSITE INTERVIEW · Seen Aug 2026
- Asteroid CollisionONSITE INTERVIEW · Seen Aug 2026
Similar questions at other companies
- Find Minimum TimeRippling · OARippling interview questions
- Minimum Days to Target EngagementTikTok · OATikTok interview questions
- Job ExecutionSnowflake · OASnowflake interview questions
- Maximizing Difference in Array Elements with Moves 🐹Microsoft · OAMicrosoft interview questions
- Minimum Time to Publish Comic BooksNutanix · OANutanix interview questions
- Find Minimum TimeAlphaSense · OA
- Find Minimum TimeBlackRock · OABlackRock interview questions
- Minimize Maximum Group DifferenceDRW · OADRW interview questions
- Minimum-Cost Solar Rooftop AllocationDeloitte · OADeloitte interview questions
- K-Means ClusteringFortinet · OAFortinet interview questions
Adobe interview experiences
- Adobe New Grad OA: Unit Conversion and Code Review: 1 Experience
- Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
- Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
- Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
- Adobe New Grad MTS Interview Questions: 7 Experiences
- Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)