FastPrepJob Execution
Problems/Job Execution

Job Execution

MathWorks logoMathWorks● MediumNEW GRADOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

There are n jobs that can be executed in parallel on a processor, where the execution time of the jth 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[i] 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

getMinimumOperations(executionTime: int[], x: int, y: int) → int

Complete the function getMinimumOperations in the editor below.

getMinimumOperations has the following parameters:

  1. int executionTime[n]: the execution times of each job
  2. int x: the time for which the major job is executed
  3. int y: the time for which all other jobs are executed

Returns int: the minimum number of operations in which the processor can complete the jobs

Examples

Example 1

executionTime = [3, 4, 1, 7, 6]x = 4y = 2return = 3

The following strategy is optimal using 1-based indexing. 1. Choose job 4 as the major job and reduce the execution times of job 4 by x and of other jobs by y. So, executionTime = [1, 2, -1, 1, 4], Job 3 is complete, so it is removed. 2. Choose job 5 as the major job and reduce the execution times of job 5 by x and of other jobs by y. So, executionTime = [-1, 0, -3, -1, 2], Jobs 1, 2, and 4 are now complete. 3. Choose job 5, executionTime = [-3, -2, -5, -3, -4], Job 5 is complete. It takes 3 operations to execute all the jobs so the answer is 3.

Constraints

  • 1 ≤ n ≤ 10^5
  • 1 ≤ executionTime[i] ≤ 10^9^
  • 1 ≤ y < x ≤ 10^9

More MathWorks interview questions

  • Earliest Time to Schedule a MeetingOA · Seen Nov 2026
  • Minimum Cost to Serve Requests on a RingOA · Seen Nov 2026
  • Minimum Tree Diameter After Removing K LeavesOA · Seen Nov 2026
  • Cities on Shortest Delivery RoutesOA · Seen Nov 2026
  • Repeated Mirror XOROA · Seen Nov 2026
  • Beautiful ArrangementONSITE INTERVIEW · Seen Jul 2026
  • Find Minimum Cost to Remove Array ElementsONSITE INTERVIEW · Seen Jul 2026
  • Group Shifted StringsONSITE INTERVIEW · Seen Jul 2026
  • Longest Valid ParenthesesONSITE INTERVIEW · Seen Jul 2026
  • Balancing TeamsOA · Seen Nov 2025

Similar questions at other companies

  • Capacity to Ship Packages Within DaysMicrosoft · OA · ONSITE INTERVIEWMicrosoft interview questions
  • Rock JumpingIMC Trading · OAIMC Trading interview questions
  • Minimum Robot and Human Fulfillment TimeAmazon · OA
  • Minimize Maximum Group DifferenceDRW · OADRW interview questions
  • Array NullificationQRT · OA
  • Minimum-Cost Solar Rooftop AllocationDeloitte · OADeloitte interview questions
  • Three-Part Partition with Minimum Largest RangeLSEG · OALSEG interview questions
  • K-Means ClusteringAtlassian · OAAtlassian interview questions
  • Get Minimum Development TimeSalesforce · OASalesforce interview questions
  • Police Station 🚓The D.E. Shaw Group · OAThe D.E. Shaw Group interview questions

MathWorks interview experiences

  • MathWorks SWE Intern Phone Screens: 1 Experience
  • MathWorks Software Engineer in Test OA and HireVue: 1 Experience
All MathWorks interview questionsSee MathWorks hiring insights
Saved
class Solution {
    public int getMinimumOperations(int[] executionTime, int x, int y) {
      // write your code here
    }

}
Checking account…