Get Priorities after Execution 🥭
Several processes are scheduled for execution on an AWS server.
On one server, n processes are schedule where the ith process is assigned
a priority of priority[i]. The processes are placed sequentially in a queue
and are numbered 1, 2,..,n. The server schedules the processes per the following algorithm:
p. (if there is no such priority or p = 0, the algorithm is terminated)p, call them process1 and process2.process1 and removes it from the queue.process2 to floor(p/2).Given the initial priority of the processes, find the final priority of the processes which remain after the algorithm terminates.
Note that relative the arrangement of remaining processes in the queue remains the same,only their priorities change.
Complete the function getPrioritiesAfterExecution in the editor.
getPrioritiesAfterExecution has the following parameter:
-
int priority[n]:the initial prorities of processes
Returns
-
int[]:the final priorities of the remaining processes
1Example 1

2Example 2

3Example 3
Constraints
Limits and guarantees your solution can rely on.
1. 1 <= n <= 105
2. 1 <= priorities[i] <= 109