FastPrepDetect a Silent Sensor
Problems/Detect a Silent Sensor

Detect a Silent Sensor

Confluent logoConfluent● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Firsthand reports describe sensor IDs and pings with timestamps, a wasAlive(sensorID, startTime) check, and failure after three inactive 100ms slots in a row. They also mention a hash-map and binary-search speedup. We chose a fixed horizon of five slots, half-open edges, an input of sorted pings for one sensor, and the numeric limits. The reports do not agree on one horizon for all cases. Our version is about 86% the same as the reported questions.

You are given the nondecreasing ping timestamps, in milliseconds, for one sensor and a query start time queryTime in milliseconds.

For this exercise, assume a fixed observation horizon of five consecutive half-open slots, each 100 milliseconds long:

  • slot 0 is [queryTime, queryTime + 100),
  • slot 1 is [queryTime + 100, queryTime + 200),
  • and so on through slot 4, ending at queryTime + 500.

A slot is active when it contains at least one ping. Return false if any three consecutive slots are inactive; otherwise return true. A ping at a slot's right boundary belongs to the next slot. Pings before the horizon or at its final endpoint do not affect the result.

The input array has already been selected from a per-sensor index, so pings belonging to other sensors are outside this function's contract.

Interview follow-ups

  • Start with raw (sensorID, timestamp) events and expose wasAlive(sensorID, startTime). Explain how to index timestamps separately for each sensor.
  • Compare scanning the sensor's entire history with binary searching the sorted timestamps at slot boundaries. Account separately for preprocessing and repeated-query costs.

Function

wasAlive(pingTimestamps: int[], queryTime: int) → boolean

Examples

Example 1

pingTimestamps = [0,50,300]queryTime = 0return = true

Slots 1 and 2 are empty; slots 0 and 3 contain pings, so there is no run of three empty slots.

Example 2

pingTimestamps = [0,20,400]queryTime = 0return = false

Slots 1, 2, and 3 are empty, so the sensor is down.

Example 3

pingTimestamps = [99,100,299,500]queryTime = 0return = true

Pings at 99, 100, and 299 fall in slots 0, 1, and 2. The ping at 500 is outside the observation horizon.

Constraints

  • 0 <= pingTimestamps.length <= 200000.
  • 0 <= pingTimestamps[i] <= 1000000000.
  • pingTimestamps is sorted in nondecreasing order.
  • 0 <= queryTime <= 999999500.

More Confluent Onsite Interview questions

  • Implement tail -nPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Sudoku Board ValidationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Sudoku Puzzle SolverPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Sequential Phrase Search Across DocumentsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Bounded Combination Sum with Signed CandidatesONSITE INTERVIEW · Seen Oct 2026
  • Build an Inverted Document IndexONSITE INTERVIEW · Seen Sep 2026
  • Combination Sum with Unlimited ReuseONSITE INTERVIEW · Seen Sep 2026
  • Word Search Across DocumentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Windowed Key-Value MapPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2025
  • Get Best PriceONSITE INTERVIEW · Seen Apr 2025

Similar questions at other companies

  • Online Meeting Scheduler with Fixed RoomsUber · ONSITE INTERVIEW
  • Index of the Maximum After Left RotationsChubb · OA
  • Rolling MetricsAkuna Capital · OA
  • Forward Block Placement QueriesCapital One · OA
  • Sorted Insertion SnapshotsSquarepoint Capital · PHONE SCREEN
  • Souvenir Shop PurchasesAmazon · OA
  • Finish Ordered CPU Tasks with the Fewest CPUsGoogle · PHONE SCREEN
  • The OraclesRubrik · OA
  • Customer Bootstrap APIDoorDash · PHONE SCREEN · ONSITE INTERVIEW
  • Search a Row- and Column-Sorted MatrixByteDance · ONSITE INTERVIEW
See Confluent hiring insights
Saved
class Solution {
    public boolean wasAlive(int[] pingTimestamps, int queryTime) {
        // Write your code here.
    }
}
Checking account…