Back to problems

Merge Step Functions of (timestamp, value) Pairs

Algorithm · Uber · Medium

You receive two timestamped arrays, a and b, that each represent a step function over time. Each item is [t, v], meaning that the function has value v on the segment that ends at t and begins immediately after the preceding checkpoint. The timestamps in both arrays are sorted. More precisely, suppose a contains checkpoints t_1 < t_2 < ... < t_n with corresponding values v_1, ..., v_n. Its value is v_k throughout the half-open interval (t_{k-1}, t_k], with t_0 = -infinity.…

Checking your access…