Compute Max Drawdown and Longest Underwater Stretch for a Pod
Last updated: November 29, 2026
Quick Overview
Given a pod's cumulative daily PnL series, return the maximum peak-to-trough drawdown, the peak and trough indices, and the longest number of days spent below a prior high-water mark.
Millennium
November 29, 20260
0
0 solved
Given a pod's cumulative daily PnL series, return the maximum peak-to-trough drawdown, the peak and trough indices, and the longest number of days spent below a prior high-water mark.
Millennium's risk framework cuts capital to teams that breach drawdown limits, so drawdown math is everyday vocabulary there. As an assessment problem it checks a single-pass running-maximum solution and careful definitions, especially for the underwater period that has not recovered by the end of the series.
What the Interviewer Expects
- Uses one pass with a running high-water mark
- Distinguishes drawdown depth from drawdown duration
- Counts an unrecovered final stretch toward the longest underwater period
- Returns indices, not only the value
- Mentions percentage drawdown versus dollar drawdown
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you compute drawdown in percent of capital when capital changes over time?
- How would you compute rolling 30-day max drawdown for many pods efficiently?
- What is the relation between drawdown and the Calmar ratio?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list of cumulative PnL values. Drawdown at day i is peak_so_far - pnl[i]. Underwater duration runs from the day a peak is set until the first day PnL reaches or exceeds it (or the end of the ...
High-Level Design
Walk once, tracking the high-water mark and its index. When below the peak, update the best drawdown and remember when the underwater stretch began. When a new high is reached, close the stretch....