Maximum stability of a server group
A cloud provider offers n servers. Server i has two positive integer scores: reliability[i] and availability[i].
A client deploys on any non-empty group of servers. A group is only as available as its weakest member, and its reliabilities add up. So the stability of a group is:
stability = min(availability of servers in the group) * sum(reliability of servers in the group)
Implement get_max_stability(reliability, availability) that returns the largest stability any group can reach. The value can be very large, so return it modulo 10^9 + 7. Pick the group by its true stability, not by the reduced value.
Constraints
1 <= n <= 10^5len(reliability) == len(availability) == n1 <= reliability[i], availability[i] <= 10^6
Example 1
reliability = [2, 3, 1]
availability = [5, 1, 4]
output: 12
Choose servers 0 and 2. The minimum availability is 4 and the reliabilities sum to 3, so the stability is 12. Server 0 alone scores 10, and all three servers score only 6.
Example 2
reliability = [10, 1]
availability = [1, 100]
output: 100
Server 1 alone scores 100 * 1 = 100. Adding server 0 drops the minimum availability to 1, for a score of 11.
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. Free with an account: one full answer per company.
