←ENG-DSA-068Compute Fleet Upgrades (Binary Search on Answer)
00:00
🐍 Python Idle
Mode:Web

Compute Fleet Upgrades (Binary Search on Answer)

CompaniesAWS, Airbnb
Est. Time~40 min
LevelMid
Binary SearchArraysMath
🚨 P0 Incident
AWSAirbnb

AWS needs to patch a fleet of servers distributed across different clusters. An automated script patches servers at a rate of K servers per hour. The patch window closes in H hours. If the script finishes a cluster early, it idles for the rest of the hour. We need to find the absolute minimum speed K that guarantees all servers are patched before the deadline.

πŸ“₯ Assigned to:You β€” Mid Engineer
Your Task

Given an array of clusters representing the number of servers in each, and a deadline `H` hours. You can patch `K` servers per hour. If a cluster has fewer than `K` servers, you patch them and idle for the rest of the hour. Return the minimum integer `K` such that all servers are patched within `H` hours.

⏱ Time: O(N log M) where M is max cluster sizeπŸ’Ύ Space: O(1)
Example 1
Input:Β Β clusters=[3,6,7,11], H=8
Output:Β 4
Example 2
Input:Β Β clusters=[30,11,23,4,20], H=5
Output:Β 30
πŸ”’ +3 hidden test cases β€” revealed on Submit
Hints
Loading editor…
Test Output
β–Ά Run Code to test against examples Β· Submit to judge all 5 test cases
EngPrep β€” Real Engineering. Real Interviews.