Busiest Rolling Hour of Completed Trips for a Driver
Last updated: November 29, 2026
Quick Overview
Given sorted trip completion timestamps in seconds for one driver, return the maximum number of trips completed within any window of 3600 seconds (inclusive of both ends).
Uber
November 29, 20260
0
0 solved
Given sorted trip completion timestamps in seconds for one driver, return the maximum number of trips completed within any window of 3600 seconds (inclusive of both ends).
A typical Uber online assessment warm-up drawn from driver activity analytics, such as spotting suspicious trip bursts or peak productivity. The grader checks the fixed-duration two-pointer window over sorted timestamps and careful handling of the inclusive boundary.
What the Interviewer Expects
- Exploit the sorted order with two pointers
- Define the window inclusively and stick to it
- Avoid O(n^2) nested scanning
- Return 0 for empty input
- Explain how this extends to unsorted input
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
- What if timestamps are not sorted?
- Return the window start time as well
- How would you compute the busiest hour for every driver in a large log efficiently?
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: non-decreasing list
tsof integers, window lengthw = 3600seconds. - A window covers trips with
ts[right] - ts[left] <= w. - Output: the maximum count of trips in such a window....
High-Level Design
Slide right across the array. For each new trip, advance left while ts[right] - ts[left] > w. The trips left..right then all lie within w seconds of each other, and any optimal window can be...