Find the Minimum Gateway Rate to Clear Order Bursts

Last updated: November 29, 2026

Quick Overview

Order bursts arrive at known millisecond timestamps, and the exchange gateway can send at most r orders per millisecond. Find the smallest integer r so that every order is sent by a given deadline.

Akuna Capital
Coding & Algorithms
Software Engineer
Akuna Capital
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Medium

0

0

0 solved


Order bursts arrive at known millisecond timestamps, and the exchange gateway can send at most r orders per millisecond. Find the smallest integer r so that every order is sent by a given deadline.

Exchanges impose message rate limits, and Akuna Capital's quoting systems must refresh thousands of option quotes when the underlying moves without breaching them. The online assessment version checks binary search on the answer with a correct monotone feasibility check and careful off-by-one handling of time.

What the Interviewer Expects
  • Notice feasibility is monotone in r, so binary search applies
  • Write an O(n) simulation for a fixed rate
  • Get the time convention right: an order arriving at ms t can send in ms t
  • Bound the search between 1 and the total order count
  • Handle arrivals after the deadline as infeasible
Key Topics to Cover
binary search on answer
simulation
rate limiting
greedy
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 the answer change if unsent orders expire after 5 ms?
  • Can you compute the answer directly without binary search?
  • How would you prioritize cancels over new quotes under the same limit?
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

Input: bursts as (arrival_ms, count) and a deadline ms. In each millisecond from arrival onward, up to r queued orders are sent. Return the minimum integer r so the queue is empty at the end of the de...

High-Level Design

If rate r works, any larger rate works too, so feasibility is monotone. Binary search r on [1, total]. For a fixed r, simulate between arrival times: during a gap of g milliseconds the queue shrinks b...


Submit Your Answer
Markdown supported

Related Questions