DRW Coding Interview Questions
25 DRW coding interview problems with full optimal solutions — 8 easy, 12 medium, 5 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an DRW interviewer values, and a FAQ section.
- #1easyvery frequently asked
1. Two Sum
DRW uses Two Sum as a rapid-fire calibration question — they want to see the hash-map instinct fire in under 30 seconds. At a firm where order-matching engines process millions of ticks per second, the difference between O(n) and O(n²) lookup is not theoretical.
- #3mediumvery frequently asked
3. Longest Substring Without Repeating Characters
DRW uses this problem to test the sliding-window pattern — the same technique that powers rolling-window deduplication on market-data feeds and tick-data deduplication in low-latency pipelines. Getting to O(n) with a single hash-map pass is required; naive O(n²) solutions are rejected on sight.
- #4hardfrequently asked
4. Median of Two Sorted Arrays
DRW uses this as a pure algorithmic-difficulty benchmark — O(log(min(m,n))) via binary search on the smaller array. The connection to trading is direct: computing the combined median bid-ask spread from two sorted venue feeds without merging them. Sub-O(n) is the only acceptable answer.
- #15mediumfrequently asked
15. 3Sum
DRW asks 3Sum to test whether candidates can combine sorting with two-pointer sweeps and suppress duplicates without extra memory. In trading contexts this pattern appears in three-asset arbitrage detection: find all triplets of prices summing to zero profit after costs.
- #20easyfrequently asked
20. Valid Parentheses
DRW surfaces Valid Parentheses as a proxy for expression-tree reasoning — a skill that maps directly to parsing FIX protocol tags, validating order-routing rule expressions, and interpreting nested config syntax in trading systems.
- #21easyfrequently asked
21. Merge Two Sorted Lists
DRW uses Merge Two Sorted Lists as a building block — it is the O(n+m) merge step inside merge-sort, inside merge-k-sorted-lists, inside order-book consolidation. Get this right cleanly and quickly; interviewers use it to see pointer discipline before escalating to the k-way variant.
- #23hardvery frequently asked
23. Merge K Sorted Lists
DRW asks Merge K Sorted Lists as a direct proxy for order-book consolidation: merge k sorted streams of price-level updates — one per venue — into a single sorted output. The min-heap approach is expected; naive pairwise merging is rejected. Throughput analysis is a required companion question.
- #42hardfrequently asked
42. Trapping Rain Water
DRW uses Trapping Rain Water as a signal-processing proxy: the 'trapped water' at each bar is analogous to the gap between realized P&L and the maximum achievable — a measure of strategy drag bounded by the maximum left and right extrema. Two-pointer O(n) is the expected answer; DRW wants to see the transition from O(n) space to O(1).
- #49mediumfrequently asked
49. Group Anagrams
DRW uses Group Anagrams to test hash-key design — the skill of choosing a canonical representation that correctly groups equivalent items. In trading systems this appears in instrument deduplication: grouping ticker aliases (GOOG / GOOGL, different listings of the same underlying) by a canonical identifier.
- #53easyfrequently asked
53. Maximum Subarray
DRW frames Maximum Subarray as a drawdown-analysis problem: find the contiguous period with the maximum cumulative return. Kadane's algorithm is the expected answer — and DRW will ask you to extend it to track the actual window start and end indices, then to compute it over a live return stream.
- #56mediumfrequently asked
56. Merge Intervals
DRW frames Merge Intervals as an order-book depth aggregation problem: given a set of bid or ask price-quantity intervals, collapse overlapping ranges into consolidated depth levels. Sorting by start time is mandatory; the merge sweep is O(n).
- #66easyfrequently asked
66. Plus One
DRW uses Plus One to probe carry-propagation logic — a primitive that appears in arbitrary-precision integer arithmetic, price tick increments, and sequence-number rollover in market-data protocols. The edge case of all-nines reveals whether you think about overflow by default.
- #70easyfrequently asked
70. Climbing Stairs
DRW uses Climbing Stairs to probe whether candidates recognize Fibonacci-structure recurrences and immediately space-optimize. The follow-up — counting paths under a step-size constraint — mirrors the combinatorics in option-path counting and lattice models.
- #121easyvery frequently asked
121. Best Time to Buy and Sell Stock
At DRW, this is not just a coding question — it is a trading question in disguise. The optimal-entry / optimal-exit framing maps directly to how DRW thinks about position entry timing in its proprietary strategies. Expect the follow-up to jump from O(n) code to expected-value maximization under uncertainty.
- #139mediumfrequently asked
139. Word Break
DRW surfaces Word Break to test DP on string segmentation — a pattern that maps to parsing FIX tag-value sequences and tokenizing structured market messages where the dictionary of valid tokens is known in advance.
- #146mediumvery frequently asked
146. LRU Cache
DRW uses LRU Cache because low-latency market-data systems rely on exactly this design: a bounded cache of recently-seen instrument snapshots, where the stale entry is evicted on each new quote. O(1) get and put are non-negotiable — the interviewer will ask for the doubly-linked-list proof.
- #200mediumfrequently asked
200. Number of Islands
DRW uses Number of Islands as a graph traversal proxy — the same connected-component logic appears in counterparty exposure clustering and in detecting isolated market segments. BFS and DFS both work; interviewers ask you to compare them on memory use.
- #206easyfrequently asked
206. Reverse Linked List
DRW asks Reverse Linked List to test pointer manipulation under pressure — a skill that maps to low-level ring-buffer and lock-free queue implementations used in market-data feed processing.
- #207mediumfrequently asked
207. Course Schedule
DRW uses Course Schedule to probe topological sort and cycle detection — the same logic used in dependency resolution for trading system component startup ordering and in detecting circular position-dependency chains in risk models.
- #238mediumfrequently asked
238. Product of Array Except Self
DRW uses this problem to test prefix-product reasoning without division — the same technique used to compute portfolio-weight normalization factors and running exposure metrics without re-scanning the full array. The O(n) no-division constraint is the key DRW signal.
- #239hardvery frequently asked
239. Sliding Window Maximum
Sliding Window Maximum is a core primitive at DRW: rolling high-water mark over a price series, rolling maximum volume over the last k ticks, rolling max drawdown window. The monotone deque gives O(n) total — O(1) amortized per tick. DRW asks why O(n log k) with a heap is insufficient at 10M ticks/second.
- #295mediumvery frequently asked
295. Find Median from Data Stream
Running median over a live stream is a first-class problem at DRW: median bid-ask spread, median fill latency, median position size across strategies. The two-heap technique gives O(log n) insertion and O(1) query. DRW will ask for the Fenwick tree variant when values are bounded integers.
- #322mediumfrequently asked
322. Coin Change
DRW uses Coin Change to test unbounded knapsack DP — and immediately connects it to tick-size discretization: given a set of valid price increments (tick sizes), what is the minimum number of ticks to express an order quantity? The greedy approach fails for arbitrary denominations; DP is required.
- #347mediumfrequently asked
347. Top K Frequent Elements
DRW asks Top K Frequent Elements to probe heap vs. bucket-sort trade-offs — decisions that matter when ranking the k most-traded instruments by volume or the k most-active order IDs in a session. O(n log k) with a heap is expected; O(n) with bucket sort earns extra credit.
- #1235hardfrequently asked
1235. Maximum Profit in Job Scheduling
DRW asks this problem because it is structurally identical to optimal trade-scheduling with non-overlapping execution windows: given a set of potential trades each with a start time, end time, and expected profit, select a non-overlapping subset that maximizes total profit. Weighted interval scheduling with binary search is the expected approach.