Compute Peak Intraday Notional From Overlapping Trader Positions

Last updated: November 29, 2026

Quick Overview

Each position is open over a half-open minute interval [open, close) with a notional amount. Return the maximum total notional open at any instant and the first minute at which that peak is reached.

J.P. Morgan
Coding & Algorithms
Software Engineer
J.P. Morgan
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Each position is open over a half-open minute interval [open, close) with a notional amount. Return the maximum total notional open at any instant and the first minute at which that peak is reached.

J.P. Morgan risk technology teams care about intraday exposure limits on trading desks, so interval questions in the technical screen are often dressed as positions or margin usage. The interviewer is checking that you convert intervals into a sweep line, handle simultaneous open and close events correctly, and can explain why sorting order matters.

What the Interviewer Expects
  • Turn each interval into a +notional open event and a -notional close event
  • Process all events at the same timestamp together before reading the running total
  • Treat intervals as half-open so a close and an open at the same minute do not overlap
  • Report O(n log n) time and justify it
  • Handle empty or zero-length positions
Key Topics to Cover
sweep line
intervals
sorting
prefix sums
risk limits
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 many queries of the form 'peak exposure between minutes a and b'?
  • What changes if positions stream in live and you must alert as soon as a limit is crossed?
  • How would you also return which positions were open at the peak?
  • If timestamps were bounded to 1440 minutes, could you beat O(n log n)?
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 (open_min, close_min, notional) with non-negative notionals. A position contributes during [open, close). Output: (peak, first_minute), or (0, None) if nothing is ever open. Cla...

High-Level Design

A sweep line: create events (time, +n) and (time, -n), sort by time, then walk them keeping a running total. The subtle part is ties. Rather than relying on sort order inside a timestamp, I consum...


Submit Your Answer
Markdown supported