FastPrepService Timeout Detection
Problems/Service Timeout Detection

Service Timeout Detection

IBM logoIBM● EasyFULLTIMENEW GRADOA
QuestionFunctionExamplesConstraints

Problem statement

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.

Function

detectTimedOutServices(timestamps: int[], serviceIds: String[], threshold: int) → String[]

Examples

Example 1

timestamps = [10, 20, 80, 10, 65]serviceIds = ["svc1", "svc1", "svc1", "svc2", "svc2"]threshold = 30return = ["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^5
  • 1 <= timestamps[i] <= 10^9
  • 0 <= threshold <= 10^9

More IBM problems

  • Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
  • Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
  • Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
All IBM interview questionsSee IBM hiring insights
Saved
class Solution {
    public String[] detectTimedOutServices(int[] timestamps, String[] serviceIds, int threshold) {
      // write your code here
    }

}
Checking account…