Heartbeat events are recorded with a timestamp and a service identifier. A service times out if the gap between any two consecutive heartbeats for that service is strictly greater than a given threshold.
Return all service identifiers that time out at least once, sorted lexicographically.
Examples
01 · Example 1
timestamps = [10, 20, 80, 10, 65] serviceIds = ["svc1", "svc1", "svc1", "svc2", "svc2"] threshold = 30 return = ["svc1", "svc2"]
svc1 has a 60-second gap between heartbeats at 20 and 80, and svc2 has a 55-second gap between 10 and 65. Both exceed the threshold.
Constraints
1 <= n <= 2 * 10^51 <= timestamps[i] <= 10^90 <= threshold <= 10^9
More IBM problems
- Count Descending SubarraysOA · Seen Apr 2026
- Count Power Products in RangeOA · Seen Apr 2026
- Minimum Operations to Make Alternating Binary StringSeen Feb 2026
- Minimum Number of Non-Empty Disjoint SegmentsSeen Feb 2026
- Count Unstable ProcessesOA · Seen Feb 2026
- Longest Balanced Binary SubarrayOA · Seen Feb 2026
- Process Execution TimeOA · Seen Nov 2025
- Get Minimum OperationsSeen May 2025
public String[] detectTimedOutServices(int[] timestamps, String[] serviceIds, int threshold) {
// write your code here
}
timestamps[10, 20, 80, 10, 65]
serviceIds["svc1", "svc1", "svc1", "svc2", "svc2"]
threshold30
expected["svc1", "svc2"]
sign in to submit