FastPrepLongest Stationary Sensor Interval
Problems/Longest Stationary Sensor Interval

Longest Stationary Sensor Interval

Wayve logoWayve● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: A Wayve interview guide updated September 20, 2026 reports timestamped sensor positions and asks for the longest stationary interval under a variance threshold. This version defines population variance, exact integer comparison, contiguity, and tie handling for deterministic judging.

Sensor samples have strictly increasing timestamps and one-dimensional integer positions. A contiguous interval is stationary when its population variance is at most maxVariance.

Return the start and end timestamps of the stationary interval containing the most samples. Break ties by the smaller start index. Compare variance exactly using count × sumSquares - sum² <= maxVariance × count².

Function

longestStationaryInterval(timestamps: int[], positions: int[], maxVariance: int) → int[]

Examples

Example 1

timestamps = [10,20,30,40,50]positions = [5,5,6,20,21]maxVariance = 1return = [10,30]

The first three positions have variance below one; adding 20 exceeds the threshold.

Example 2

timestamps = [1,2,3]positions = [0,10,0]maxVariance = 0return = [1,1]

Only single-sample intervals have zero variance, so the earliest one wins.

Constraints

  • 1 <= timestamps.length = positions.length <= 2000
  • Timestamps are strictly increasing.
  • |positions[i]| <= 10000
  • 0 <= maxVariance <= 100000000

More Wayve problems

  • Factorial Without MultiplicationPHONE SCREEN
  • Non-Maximum SuppressionPHONE SCREEN
See Wayve hiring insights
Saved
class Solution {
    public int[] longestStationaryInterval(int[] timestamps, int[] positions, int maxVariance) {
      // Write your code here.
    }

}
Checking account…