Select Non-Conflicting Block Trade Windows for Maximum Edge
Last updated: November 29, 2026
Quick Overview
A desk is offered block trade opportunities, each with a start time, end time, and expected edge, and can only work one at a time. Choose a set of non overlapping opportunities that maximizes total edge and return both the total and the chosen blocks.
DRW
November 29, 20260
0
0 solved
A desk is offered block trade opportunities, each with a start time, end time, and expected edge, and can only work one at a time. Choose a set of non overlapping opportunities that maximizes total edge and return both the total and the chosen blocks.
Allocating limited trader or algorithm capacity across competing opportunities is a real concern at DRW, and the clean abstraction is weighted interval scheduling. The interviewer wants the 1D DP with binary search for the previous compatible interval, plus reconstruction of the choice, not just the number.
What the Interviewer Expects
- Explains why greedy by edge or by end time fails with weights
- Sorts by end time and defines dp over prefixes
- Finds the last compatible block with binary search
- Reconstructs the chosen set
- Gives O(n log n) time
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
- The desk can run two blocks concurrently: how does the DP change?
- Edge is uncertain with a variance: how would you choose under a risk penalty?
- Opportunities arrive online and must be accepted or declined immediately. What can you guarantee?
- How would you handle a minimum gap between blocks?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Blocks are (start, end, edge) with edge >= 0. A block ending at t is compatible with one starting at t. Output: max total edge and the blocks in time order....
High-Level Design
Sort by end time. Let dp[i] be the best value using only the first i blocks. For block i either skip it (dp[i-1]) or take it plus the best among blocks that end by its start (dp[p(i)] + w). Beca...