Amazon Execute Processes (a.k.a. AWS Processor)
Learn this problemProblem statement
Amazon Web Services (AWS) has several processors for executing processes scheduled on its servers.
There are n processes to be executed, where the ith process takes
execution[i] amount of time to execute. Two processes are cohesive if and only if
their original execution times are equal. When a process with execution time execution[i]
is executed, it takes execution[i] time to complete and simultaneously reduces the
execution time of all its cohesive processes to ceil(execution[i] / 2).
Given the execution time of n processes, find the total amount of time the processor
takes to execute all the processes if you execute the processes in the given order, i.e. from left
to right.
Notes
ceil() function returns the smallest integer that is bigger or equal to its argument. For example, ceil(1.1) = 2, ceil(2.5) = 3, ceil(5) = 5, etc.i is reduced and becomes equal to the execution time of any other process j, then the two processes i and j are not considered cohesive.Function
totalExecutionTime(execution: int[]) → int
Complete the function totalExecutionTime in the editor.
totalExecutionTime has the following parameter:
int execution[n]: an array of integers representing the execution timesReturns
int: the total amount of time to execute all processesExamples
Example 1
execution = [5, 5, 3, 6, 5, 3]return = 21
Constraints
Unknown for now 🐰More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026