Match Each Lidar Sweep to the Nearest Camera Frame
Last updated: November 29, 2026
Quick Overview
Given sorted lidar sweep timestamps and sorted camera frame timestamps (microseconds), return for each sweep the index of the camera frame closest in time, or None if the closest frame is more than max_gap away.
Aurora
November 29, 20260
0
0 solved
Given sorted lidar sweep timestamps and sorted camera frame timestamps (microseconds), return for each sweep the index of the camera frame closest in time, or None if the closest frame is more than max_gap away.
Sensor fusion on a self-driving truck depends on pairing measurements taken at nearly the same instant, and Aurora's perception stack fuses lidar, camera and radar. This phone-screen style question checks whether you can use sorted order instead of a nested loop and whether you handle ties and gaps cleanly.
What the Interviewer Expects
- Uses binary search or two pointers instead of an O(n*m) scan
- Checks both neighbors around the insertion point
- Applies the max_gap threshold and returns None correctly
- Handles empty camera list and sweeps before the first or after the last frame
- States a tie-breaking rule
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you do this as a streaming operation when both streams arrive live with bounded jitter?
- What changes if the camera has a known fixed latency offset?
- How would you match each sweep to a frame from every one of seven cameras at once?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Inputs: lidar_ts and camera_ts, both sorted ascending, plus max_gap. Output: a list with one entry per sweep, the index of the nearest camera frame or None. On a tie (equal distance before and...
High-Level Design
For each sweep timestamp, bisect_left gives the first camera frame at or after it. The nearest frame must be that one or the one just before it, so only two candidates need checking. Because both li...