Peak Gross Notional Across Overlapping Hedge Positions

Last updated: November 29, 2026

Quick Overview

Each hedge is active on a half open time interval [start, end) with a notional amount. Compute the peak total notional held at any instant and the earliest time that peak is reached.

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

0

0

0 solved


Each hedge is active on a half open time interval [start, end) with a notional amount. Compute the peak total notional held at any instant and the earliest time that peak is reached.

Risk systems at a proprietary trading firm like DRW need to know the worst concurrent exposure, for example to size margin or check intraday limits. The interviewer uses this sweep line problem to see how you handle event ordering at shared timestamps and whether you avoid the common off-by-one on touching intervals.

What the Interviewer Expects
  • Converts intervals to start and end events
  • Gets tie ordering right so touching intervals do not overlap
  • Applies all events at a timestamp before checking the peak
  • Returns earliest time of the peak
  • States O(n log n) time
Key Topics to Cover
sweep line
intervals
sorting
event processing
risk exposure
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
  • Hedges arrive and expire in real time: how would you maintain the current exposure and a running max?
  • Answer many queries of the form: what was the exposure at time t?
  • Notionals can be negative (offsetting hedges): does anything break?
  • How would you find the peak if intervals are closed instead of half open?
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: list of (start, end, notional) with [start, end) semantics. Output: (peak, time), or (0, None) if nothing is ever active. Two hedges where one ends at 5 and the next starts at 5 never o...

High-Level Design

Turn each hedge into (start, +n) and (end, -n). Sort by time. Grouping all events at the same timestamp and applying them together before reading the running sum makes the tie rule irrelevant to c...


Submit Your Answer
Markdown supported

Related Questions