Uber Onsite Coding Question | 2022
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2022-04-30Added By Anonymous
Source: Link
Company: Uber
Interview Stage: Onsite
Year: 2022
Original Post Content:
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:
Similar idea to interval list intersection or merge intervals questions. Linear single pass solution.