Lazily Resample an Irregular GPS Stream to a Fixed Rate
Last updated: November 29, 2026
Quick Overview
Write a generator that takes a possibly infinite stream of (t, x, y) GPS samples with irregular, increasing timestamps and yields samples on a fixed time grid by linear interpolation, skipping grid points inside gaps longer than max_gap instead of inventing data.
Applied Intuition
November 29, 20260
0
0 solved
Write a generator that takes a possibly infinite stream of (t, x, y) GPS samples with irregular, increasing timestamps and yields samples on a fixed time grid by linear interpolation, skipping grid points inside gaps longer than max_gap instead of inventing data.
Applied Intuition's log tooling normalizes sensor streams before replay and metrics, and they can be too large to load fully. The interviewer checks iterator protocol fluency, constant memory, and honest handling of data gaps.
What the Interviewer Expects
- Consume the input one sample at a time with O(1) memory
- Compute grid times as t0 + k*dt to avoid float drift
- Interpolate only between the two bracketing samples
- Skip grid points in gaps longer than max_gap, but keep exact sample hits
- Validate strictly increasing timestamps
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 emit a gap marker instead of skipping silently?
- How would you interpolate heading correctly across the 359 to 0 degree wrap?
- How would you use spline interpolation while staying streaming?
- How would you align the grid to wall-clock seconds instead of the first sample?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input is any iterable of (t, x, y). Output starts at the first sample time and steps by dt. For a grid time inside a segment longer than max_gap, yield nothing unless it lands exactly on a real samp...
High-Level Design
Keep only the previous sample. For each new sample, emit every grid point t0 + k*dt up to and including the new sample's time by interpolating between prev and cur: wit...
Submit Your Answer
Applied Intuition Software Engineer Interview Guide
Interview process, tips, and preparation timeline