#47Cloud Resource Monitoring
A cloud monitoring system tracks the resource usage of multiple virtual machines (VMs). Each VM has a numerical resource-usage value, such as CPU usage, memory consumption, network load, or storage utilization. Given an array usage containing the resource-usage values of all VMs and an integer k, return the kth highest resource-usage value.
The value is based on sorted order, and duplicate usage values are counted separately.
For example, if the usage values are [80, 95, 80, 70] and k = 2, the sorted order is [95, 80, 80, 70], so the answer is 80.
Real-World Applications: Cloud Server Resource Monitoring; Virtual Machine Load Analysis; Data Center Capacity Planning;
Examples
Example 1
Input: usage = [65,90,45,80,95,70]
k = 2
Output: 90
Explanation: The usage values in descending order are [95,90,80,70,65,45]. The 2nd highest value is 90.
Example 2
Input: usage = [40,75,60,90,75,85,50]
k = 4
Output: 75
Explanation: The descending order is [90,85,75,75,60,50,40]. The 4th highest value is 75.
Example 3
Input: usage = [100,55,80,95,70,85]
k = 3
Output: 85
Explanation: The descending order is [100,95,85,80,70,55]. Therefore, the 3rd highest resource usage is 85.
Constraints
- 1 <= k <= usage.length <= 100000
- 0 <= usage[i] <= 100000
- Duplicate usage values are allowed.
- k represents the kth highest value, not the kth distinct value.