Peak Number of Simultaneously Resting Orders
Last updated: November 29, 2026
Quick Overview
Given each order's (placed_time, done_time) where the order rests on the book on the half-open interval [placed, done), return the maximum number of orders resting at the same instant.
Voleon
November 29, 20260
0
0 solved
Given each order's (placed_time, done_time) where the order rests on the book on the half-open interval [placed, done), return the maximum number of orders resting at the same instant.
A warm-up in the style of Voleon's phone screens, framed around execution monitoring where risk wants to know peak exposure in open orders. The interviewer wants a sweep line, a crisp answer on tie handling at equal timestamps, and correct complexity.
What the Interviewer Expects
- Ask whether intervals are open or closed at the end
- Turn intervals into +1 and -1 events and sort
- Order ties so an order ending at t is not counted with one starting at t
- State O(n log n) time and O(n) space
- Handle empty 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
- How would you report the time at which the peak occurs?
- What if each order has a share quantity and you want peak open shares?
- How would you compute this online as events arrive in time order?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Each order is resting on [start, end). An order that finishes at time 5 and another that starts at 5 never overlap. Return the max concurrent count; 0 for no orders....
High-Level Design
Rather than checking every pair, emit an event (start, +1) and (end, -1) for each order, sort by time, and walk the events keeping a running count. The peak of the running count is the answer. Bec...