Remaining Driving Time Under Combined Hours-of-Service Clocks
Last updated: November 29, 2026
Quick Overview
Given a driver's contiguous duty status log (driving, on duty, off duty, sleeper berth) and the current time, compute how many minutes the driver may still drive and which rule is binding, applying the 11-hour driving limit, the 14-hour on-duty window, the 30-minute break after 8 hours of driving, and a 10-hour off-duty reset.
Motive
November 29, 20260
0
0 solved
Given a driver's contiguous duty status log (driving, on duty, off duty, sleeper berth) and the current time, compute how many minutes the driver may still drive and which rule is binding, applying the 11-hour driving limit, the 14-hour on-duty window, the 30-minute break after 8 hours of driving, and a 10-hour off-duty reset.
The remaining-time clocks on Motive's driver app are what drivers plan their day around, and dispatchers use the same numbers to assign loads, so a bug is a compliance and safety problem. This onsite problem tests whether you can model several interacting rules cleanly, choose the right reset semantics, and explain your simplifications.
What the Interviewer Expects
- Model each rule as its own clock and take the minimum
- Start the 14-hour window at the first on-duty or driving minute after a reset, and do not pause it for breaks
- Combine OFF and SB toward the 10-hour reset, but let any non-driving status count toward the 30-minute break
- Treat time between the last segment and now as off duty, and say so
- Return the binding rule so the UI can explain it
- State the real-world rules that were left out (split sleeper, 60/70 hour cycle, adverse conditions)
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 add the 60-hour in 7 days or 70-hour in 8 days cycle limit with a 34-hour restart?
- How would you support the split sleeper berth provision?
- How would you recompute clocks efficiently when a driver edits a segment from yesterday?
- How would you test this given the cost of being wrong?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Segments are (status, start, end) in minutes, sorted and contiguous. Rules in this simplified model: at most 660 minutes driving after a reset; no driving after 840 minutes from the window start; af...
High-Level Design
One pass maintaining window_start, drive_used, since_break, off_run (consecutive OFF/SB) and rest_run (consecutive non-driving of any kind). A shared rest() helper handles break and reset ...