Extract Sustained Speeding Intervals From Vehicle Speed Pings

Last updated: November 29, 2026

Quick Overview

Given time-sorted pings of (timestamp seconds, speed mph, posted limit mph), return each interval where the vehicle stayed more than a tolerance over the limit for at least a minimum duration, along with the peak amount over, splitting intervals when pings are too far apart.

Motive
Coding & Algorithms
Software Engineer
Motive
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

0

0 solved


Given time-sorted pings of (timestamp seconds, speed mph, posted limit mph), return each interval where the vehicle stayed more than a tolerance over the limit for at least a minimum duration, along with the peak amount over, splitting intervals when pings are too far apart.

Speeding events feed Motive's safety scores, coaching, and the fleet manager's event feed, and a single noisy ping must not create an alert. This kind of question checks whether you can group consecutive readings into runs with clear thresholds for tolerance, duration, and data gaps.

What the Interviewer Expects
  • Ask what counts as over the limit and whether the tolerance is strict
  • Treat a gap larger than max_gap as breaking the run, since you cannot claim speeding with no data
  • Only emit runs that meet the minimum duration
  • Track the peak overage per run
  • Linear time, handle the run still open at the end
Key Topics to Cover
run length grouping
streaming events
thresholds
telematics
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you make the tolerance a percentage that varies by road type?
  • How would you do this as a streaming function that emits events as pings arrive?
  • What if the posted limit is missing for some pings?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Pings are (t, speed, limit) sorted by time. A ping is over when speed - limit > tolerance (defaults: 5 mph, 30 seconds minimum, 10 second max gap). A run is consecutive over pings with no gap abov...

High-Level Design

Scan once, keeping the open run's start, last and peak. An over ping either extends the run or, if the gap from last is too big, closes the old run and starts a new one. A ping that is not ove...


Submit Your Answer
Markdown supported

Related Questions