As reported: BlackRock Associate, Java backend developer (Mumbai), interview 1 (45 minutes on HackerRank CodePair), Mar 2026: the Process Scheduling problem below, then the character frequency of a string, then Java and Spring questions. The heap approach (pop the largest, subtract, push back half) was used.
A multiprocessor system has n processors; ability[i] is the number of processes processor i can schedule in one second. Every second you choose one processor and use it to schedule up to its current ability; after it is used, its ability becomes floor(ability / 2). Given the number of processes processes, find the minimum number of seconds needed to schedule all of them.
Example
ability = [3,1,7,2,4], processes = 15 -> 4
Use the processor with 7 (8 left; it drops to 3), then 4 (4 left; drops to 2), then 3 (1 left), then the other 3 (done).
Constraints: 1 ≤ ability.length ≤ 10^5; 1 ≤ ability[i] ≤ 10^6; 1 ≤ processes ≤ 10^12. It is guaranteed that all processes can be scheduled.
Code runner format: one JSON value per line: ability, then processes. Implement minimumTime(ability, processes); the harness prints the number of seconds. processes needs a 64-bit integer.