Voleon Interview #5 – Traded Volume (Sliding-Window Market Data Processing, HFT, Quant OA)

25 Views
No Comments

Input (stdin)
The program reads the input line by line. Each line must be one of the following message types:

• A print represents a trade that took place on the exchange:

print <timestamp> <security> <quantity> <price>

• A volume check is a request to report the total traded quantities of a security in the preceding minute, as well as its latest price:

volume-check <timestamp> <security>

Fields are space-delimited and defined as follows:

  • timestamp: seconds since market open (non-negative integer). Timestamps are guaranteed to be monotonically non-decreasing.
  • security: alphabetical string.
  • quantity: positive integer.
  • price: positive integer.

Output (stdout)

For each volume check request for security S at time T, emit the following line:

traded-volume T S <volume> <price>

Where:

  • volume = sum of traded quantities in all prints of S whose timestamps > T-60 (zero if none)
  • price = price in the most recent print for S (zero if none)

Volume check responses must be emitted before processing subsequent input.


Example

Input

print 9 SILVER 30 11
print 12 SILVER 100 12
print 29 PEARL 25 99
print 37 SILVER 10 14
volume-check 69 SILVER
print 71 PEARL 25 100
volume-check 99 SILVER
volume-check 99 PEARL

Output

traded-volume 69 SILVER 110 14
traded-volume 99 SILVER 0 0
traded-volume 99 PEARL 25 100

Summary

This problem tests your ability to:

✅ Maintain a 60-second sliding window
✅ Aggregate volume per security
✅ Track the latest price
✅ Process messages online in timestamp order
✅ Produce outputs immediately for volume-check requests

Core data structure:
Dictionary of deques, each deque storing (timestamp, quantity, price).

The VOprep team has long accompanied candidates through various major company OAs and VOs, including Voleon, Google, Amazon, Citadel, SIG, providing real-time voice assistance, remote practice, and interview pacing reminders to help you stay smooth during critical moments. If you are preparing for Tiktok or similar engineering-focused companies, you can check out our customized support plans—from coding interviews to system design, we offer full guidance to help you succeed.

END
 0