Peak Resource Usage Across Weighted Intervals
Problem statement
Each half-open interval [start, end) consumes a positive number of resources while active. Return the maximum total resource usage at any instant.
An interval ending at time t is inactive before an interval starting at t is counted.
Function
peakResourceUsage(intervals: int[][], resources: int[]) → intExamples
Example 1
intervals = [[1,4],[3,5],[4,6]]resources = [3,2,4]return = 6Case 1 exercises the documented deterministic contract.
Example 2
intervals = [[0,1]]resources = [7]return = 7Case 2 exercises the documented deterministic contract.
Example 3
intervals = [[1,2],[2,3]]resources = [5,9]return = 9Case 3 exercises the documented deterministic contract.
Constraints
1 <= intervals.length == resources.length <= 200000.0 <= start < end <= 10^9.- The total active resource count fits a signed 32-bit integer.