Find Sustained Overspeed Intervals in a Truck Trip Log
Last updated: November 29, 2026
Quick Overview
Given a time-ordered list of (timestamp_seconds, speed_mph) samples and a speed limit, return every interval where the truck stayed strictly above the limit for at least min_duration seconds, as (first_over_ts, last_over_ts) pairs.
Aurora
November 29, 20260
0
0 solved
Given a time-ordered list of (timestamp_seconds, speed_mph) samples and a speed limit, return every interval where the truck stayed strictly above the limit for at least min_duration seconds, as (first_over_ts, last_over_ts) pairs.
Aurora's offline tooling scans drive logs for events that need review, and a speed check is one of the simplest triage rules. This assessment question checks clean run-length grouping, the closing condition at the end of the array, and careful definitions of duration.
What the Interviewer Expects
- Groups consecutive over-limit samples in one pass
- Closes an open run when the log ends
- Uses a clear definition of duration (last over sample minus first over sample)
- Treats speed equal to the limit as not over
- Returns results in time order
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 tolerate a single noisy sample below the limit inside a long overspeed run?
- What if samples are irregularly spaced and a gap of 30 seconds appears in the log?
- How would you run this over a petabyte of logs in a batch job?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Samples are sorted by time. A sample is over when speed > limit. A run's duration is last_over_ts - first_over_ts, and a run counts if that is at least min_duration. I would confirm this definit...
High-Level Design
Walk the samples once, keeping the start of the current over-limit run and the timestamp of its latest over sample. When a sample is at or under the limit, close the run if it is long enough. After th...