The Stream Joiner
A hard Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- hard
- Seniority
- L5
Problem
Given two sorted lists of event dicts (each with 'timestamp' and 'value') and a numeric tolerance, for each event in stream_a find the nearest event in stream_b whose |timestamp_a - timestamp_b| <= tolerance. If such a match exists, output {'a_value', 'b_value', 'gap'}. Events without a match are skipped. Return the output list in input-order of stream_a. If multiple stream_b events tie for nearest, choose the earliest.
Summary
Events don't wait for each other. This does.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.