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
Coding & Algorithms
Software Engineer
Voleon
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

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
sweep line
intervals
event sorting
tie breaking
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 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 Problems
Sample 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...


Submit Your Answer
Markdown supported

Related Questions