Get Min Operations
Updated
Problem statement
There are n jobs that can be executed in parallel on a processor, where the execution time of the ith job is executionTime[i]. To spped 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, the it exits the pool. Find the min num of operations in which the processor can completely execute all the jobs if run optimally.
Function
citadelGetMinOperations(executionTime: int[], x: int, y: int) → int
Complete the function citadelGetMinOperations in the editor 👉👉.
citadelGetMinOperations has the following parameters:
int executionTime[n]: the execution times for each jobint x: the time for which the major job is executedint y: the time for which all other jobs are executed executed
Returns
int: the min number of operations in which the processor can complete the jobs
Key insight:
- _optimization_
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 = 4 and of other jobs by y = 2. Now executionTime = [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 = [3, 3, 6, 3, 9]x = 3y = 2return = 3- Choose job 5, then executionTime = [1, 1, 4, 1, 6]. All jobs are still in the pool 🫨
- Choose job 5, then executionTime = [-1, -1, 2, -1, 3]. So jobs 1,2 and 4 are complete. 🍻
- Choose job 5, then executionTime = [-, -, 0, -, 0]. Jobs 3 and 5 are complete.😍
Example 3
executionTime = [2, 3, 5]x = 3y = 1return = 3- Choose job 3, then executionTime = [1, 2, 2]. All jobs are still in the pool 🤧
- Choose job 3, then executionTime = [0, 1, -1]. So jobs 1 and 3 are complete. 🥂
- Choose job 2, then executionTime = [-, -2, -]. Jobs 2 is complete.😘
Constraints
1 <= n <= 3 * 10^51 <= executionTime[i] <= 10^91 <= y < x <= 10^9
More Citadel interview questions
- Merge Price-Delta FeedsPHONE SCREEN · Seen Dec 2026
- Speed Up a Slow FunctionOA · PHONE SCREEN · Seen Nov 2026
- Portfolio Tickers with Constant-Time Random PickPHONE SCREEN · Seen Nov 2026
- Square Root FunctionPHONE SCREEN · Seen Oct 2026
- Reachable Transfer PositionsPHONE SCREEN · Seen Oct 2026
- Spreadsheet Formula DependenciesPHONE SCREEN · Seen Oct 2026
- Possible MEX Values After One Optional IncrementOA · Seen Oct 2026
- Currency Arbitrage CyclePHONE SCREEN · Seen Sep 2026
- Order Book with Cancel by Order IDPHONE SCREEN · Seen Sep 2026
- Smart Queue of Latest PricesPHONE SCREEN · Seen Sep 2026
Similar questions at other companies
- Minimum BeautyBloomberg LP · OABloomberg LP interview questions
- Minimum Operations to Make a SubsequenceGoogle · OAGoogle interview questions
- Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions
- Split Array Largest SumAuxoAI · OA
- Data ReorganizationGoldman Sachs · OAGoldman Sachs interview questions
- Find Minimum TimeRippling · OARippling interview questions
- Find Optimal LevelAmazon · OA
- Minimum Days to Target EngagementTikTok · OATikTok interview questions
- Job ExecutionSnowflake · OASnowflake interview questions
- Maximizing Difference in Array Elements with Moves 🐹Microsoft · OAMicrosoft interview questions
Citadel interview experiences
- Citadel Securities Quant Researcher Intern Loop: 1 Experience
- Citadel Securities Research Engineer Interview: 1 Experience
- Citadel Securities SWE Intern First Round: 2 Experiences
- Citadel Securities Experienced SWE Interviews: 1 Experience
- Citadel SWE Intern Later Rounds and Superday: 13 Experiences
- Citadel SWE Intern First-Round Questions: 20 Experiences