FastPrepTimestamped Telemetry Stream Differences

Timestamped Telemetry Stream Differences

SpaceX logoSpaceX● EasyFULLTIMEPHONE SCREEN
Learn

Problem statement

Two telemetry streams contain aligned integer samples. Only the first stream supplies timestamps, in nondecreasing order. Arrays leftValues and rightValues contain the aligned measurements for those timestamps.

Return one row [timestamp, leftValue - rightValue] for every sample, preserving input order.

Function

telemetryDifferences(timestamps: int[], leftValues: int[], rightValues: int[]) → int[][]

Examples

Example 1

timestamps = [10,20,30]leftValues = [7,4,9]rightValues = [2,6,3]return = [[10,5],[20,-2],[30,6]]

Subtract aligned values and retain the timestamp from the first stream.

Example 2

timestamps = [5]leftValues = [-3]rightValues = [4]return = [[5,-7]]

Negative differences are retained.

Example 3

timestamps = [1,1,2]leftValues = [5,8,6]rightValues = [5,3,9]return = [[1,0],[1,5],[2,-3]]

Nondecreasing timestamps may repeat and every aligned sample is emitted.

Constraints

  • 1 <= timestamps.length <= 10^5.
  • All three arrays have the same length.
  • Timestamps are nondecreasing and every difference fits a signed 32-bit integer.

More SpaceX problems

See SpaceX hiring insights
public int[][] telemetryDifferences(int[] timestamps, int[] leftValues, int[] rightValues) {
    // Write your solution here.
}
timestamps[10,20,30]
leftValues[7,4,9]
rightValues[2,6,3]
expected[[10,5],[20,-2],[30,6]]
Checking account…