UBER | SDE2 | DSA Round

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-01-16Added By Anonymous
Source: Link

Company: Uber

Role: software engineer ii

Interview Stage: Phone Screen


Original Post Content:


Problem

Given two time series data lists,


First List

[(1, 3), (3, 1), (5,3), (6, 4), (10, 1)]


Explanation:


What this means is that at timestamp 1 the value is 3, and then at timestamp 3 the value is 1 and so on.

Note: Missing/Undefined value on any timestamp is extrapolated backwards from the next timestamp. For example, value at timestamp 2 based on the example above would be 1.


Second List


[(2, 3), (6, 3), (9, 2)]


Write a function to aggregate these two time series data into one


Answer

[(1, 6), (2, 4), (3, 4), (5,6), (6, 7), (9, 3), (10,1)]


Solution: Merge sort


Follow up

which we discuss upon for half of the interview:

What if there are N time series lists are given in above question. I gave divide and conquer approach.

Comments