API Bandwidth Allocation
Problem statement
Each API endpoint consumes bandwidth[i] units when enabled and resolves requests[i] requests. An endpoint is either enabled once or not enabled.
Given the total available maxBandwidth, return the maximum number of requests that can be resolved without exceeding the bandwidth limit.
Function
maximizeResolvedRequests(maxBandwidth: int, bandwidth: int[], requests: int[]) → intExamples
Example 1
maxBandwidth = 5bandwidth = [2,3,4]requests = [4,5,7]return = 9Case 1 exercises the documented deterministic contract.
Example 2
maxBandwidth = 7bandwidth = [2,3,4]requests = [4,5,7]return = 12Case 2 exercises the documented deterministic contract.
Example 3
maxBandwidth = 0bandwidth = [1,2]requests = [10,20]return = 0Case 3 exercises the documented deterministic contract.
Constraints
0 <= maxBandwidth <= 10000.1 <= bandwidth.length == requests.length <= 200.1 <= bandwidth[i] <= 10000.0 <= requests[i] <= 10^6.- The optimal answer fits a signed 32-bit integer.