Peak Number Of Simultaneous Taxi Orders In A Day

Last updated: November 29, 2026

Quick Overview

Given a list of taxi orders as half-open intervals [start, end) in seconds, return the maximum number of orders that are active at the same moment and the earliest time that maximum is reached.

Yandex
Coding & Algorithms
Software Engineer
Yandex
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given a list of taxi orders as half-open intervals [start, end) in seconds, return the maximum number of orders that are active at the same moment and the earliest time that maximum is reached.

Yandex Go capacity planning needs to know peak concurrent load per city, which maps to a sweep-line problem often used in an algorithmic onsite section. The interviewer looks for the event-sort approach and correct tie handling at shared endpoints.

What the Interviewer Expects
  • Turn each interval into a +1 and a -1 event
  • Sort events so that ends come before starts at equal timestamps
  • Track running count and record the time of the first maximum
  • Explain why half-open intervals drive the tie rule
  • Give O(n log n) time
Key Topics to Cover
sweep line
event sorting
intervals
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 answer the same query for many cities streaming in real time?
  • How would you compute the full concurrency curve per minute?
  • If timestamps are bounded integers in one day, can you do better than sorting?
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

An order occupies a car on [start, end), so an order ending at 10 and one starting at 10 do not overlap. Return (max_active, time); for empty input return (0, None). Orders that have not finishe...

High-Level Design

Sweep line: create events (start, +1) and (end, -1), sort by time, and for equal times put -1 first so that a finishing order frees the car before the next one starts. Keep a running sum; the ma...


Submit Your Answer
Markdown supported

Related Questions