Coding Interview Questions
Coding questions in quant interviews test the same data-structures-and-algorithms core as any software loop — arrays and sliding windows, sorting and order statistics, dynamic programming, greedy, graphs — plus two quant twists: streaming market-data problems and rapid-fire C++/Python internals.
The common thread: name the complexity target out loud, then pick the one structure that hits it.
Last updated 2 July 2026 · sub-areas, difficulty mix and firm attributions on this page are compiled directly from the 564 coding problems in the QuantVault bank; firm tags are candidate-reported, not employer-verified, and no individual author is named in our source data.
- Core sub-areas
- Arrays & sliding window · sorting & order statistics · dynamic programming · greedy & intervals · graphs · streaming & market data · language internals
- Typical difficulty
- Centered on medium — 128 easy, 313 medium and 123 hard across the 564-problem set
- Who leans on it
- Software-engineering and quant-dev tracks above all — 541 of the 564 problems carry an SWE role tag, with firm tags from Citadel, Two Sigma, Jump Trading, Tower Research, Jane Street and others
- Practice pool
- 564 problems in the bank · 40 free to open with the full worked solution
Where coding shows up: at nearly every stage for SWE and quant-dev candidates — a timed online assessment first, then live rounds where you narrate complexity trade-offs while you type; quant researchers and traders usually get a lighter scripting version. For how it sits inside specific funnels, see the Citadel interview questions guide and the Two Sigma interview questions guide.
The surfaceThe coding sub-areas quant interviews test
Eight families cover essentially every coding question in the bank. Each row pairs a sub-area with the recurring question shape and a representative type — a flavor drawn from real problems, not a leaked wording — so you can see where the difficulty actually lives.
| Sub-area | Recurring shape | Representative type (flavor, not a real question) |
|---|---|---|
| Arrays, two pointers & sliding window | Maintain a window or pointer-pair invariant in one pass | Count or bound subarrays under a sum, range or distinct-count constraint — the answer falls out of a shrinking window. |
| Sorting, searching & order statistics | Beat the obvious full sort with the right partial structure | Find a k-th smallest, a median or a runner-up with fewer comparisons than sorting everything. |
| Dynamic programming & recursion | Name the state, then the transition | An edit-distance, longest-increasing-subsequence or disjoint-subarray variant where the whole battle is defining the DP table. |
| Greedy & interval problems | Sort by the right key, sweep, and argue the exchange | Merge or schedule intervals — rooms, meetings, non-overlapping picks — where the greedy choice needs a one-line proof. |
| Graphs & grids | Model the input as a graph, then pick BFS/DFS/union-find | Connected components in a relationship matrix, or a grid shortest path with an extra movement constraint. |
| Streaming & market data | One pass, bounded memory, market-shaped input | A rolling drawdown, streaming quantile, order-book or trade-matching engine where you must state what you keep and what you drop. |
| Numerics & strings | Make the arithmetic itself robust | A numerically stable log-sum-exp, a root-finder with a tolerance, or exact arithmetic on decimal strings. |
| Language internals & class design | Rapid-fire semantics questions, no algorithm at all | What a C++ map lookup default-constructs, which special member functions the compiler generates, how a class should expose hashing. |
What's confirmed vs. what varies: the sub-areas and difficulty mix come straight from the problem set, so they are stable. Which firm asks which flavor is candidate-reported through problem tags — treat firm attributions as directional; HFT software loops weight the streaming and language-internals families hardest.
The patternsSignature coding question patterns
Three moves generate a disproportionate share of correct answers in this topic. Each worked box is a 60–90 second micro-example in the interview's actual cadence — the reasoning template on a generic setup, not any firm's wording.
Sliding window — ride the monotone invariant
Takeaway: when every element is positive, a window's sum only grows as it extends — that monotonicity is what lets two pointers replace a quadratic scan.
Shape. Given an array of positive integers, count the subarrays whose sum is less than \(K\).
1. Spot the invariant. Positivity means: extend the right end and the sum rises, retract the left end and it falls. So for each right endpoint there is a single leftmost valid start.
2. Sweep. Advance the right pointer one step at a time; while the window sum is \(\ge K\), advance the left pointer. Each pointer moves at most \(n\) times, so the pass is \(O(n)\).
3. Count in bulk. With the window \([l, r]\) valid, every start in it works: add \(r - l + 1\) to the count. The move: say “positive entries, so the window is monotone” before you code — that sentence is most of the credit.
Prefix sums + hash map — when the window breaks
Takeaway: negatives destroy window monotonicity — the fix is to hash prefix sums, turning “subarray with sum \(K\)” into a constant-time lookup.
Shape. Find the longest subarray summing to exactly \(K\), where entries may be negative.
1. Diagnose. With negatives, shrinking the window can raise the sum, so two pointers give wrong answers. This is the classic trap the easier pattern sets up.
2. Reframe. A subarray \((i, j]\) sums to \(K\) exactly when prefix sums satisfy \(P_j - P_i = K\). Store the first index at which each prefix value occurs in a hash map.
3. Sweep once. At each \(j\), look up \(P_j - K\); if seen at index \(i\), a candidate of length \(j - i\) exists. One pass, \(O(n)\) time and space. The move: window for monotone constraints, prefix-hash for exact-sum constraints — know which regime you are in.
Streaming state — decide what you keep, then defend it
Takeaway: streaming questions are really state-design questions — a monotonic deque keeps exactly the prices that could still matter, and nothing else.
Shape. Prices arrive one at a time; after each tick, report the maximum drawdown — peak minus current price — over the last \(W\) ticks.
1. Reduce. The drawdown at time \(t\) is (max price in the window) \(- \, p_t\), so the problem is a rolling-window maximum in disguise.
2. Design the state. Keep a deque of indices whose prices are strictly decreasing: pop the back while the new price beats it (those can never be a future maximum), pop the front once it ages out of the window.
3. Account for it. Each index enters and leaves the deque once: \(O(1)\) amortized per tick, \(O(W)\) memory — volunteer both bounds unprompted. The move: name what the state represents (“still-viable maxima”), and the code writes itself.
Free practiceCoding practice questions by sub-area
All 40 free problems from the 564-problem coding set, grouped by the sub-areas above and ordered easy → hard within each group — every link opens the full worked solution. One honesty note: the free pool runs 6 easy, 25 medium and 9 hard, a slightly gentler mix than the full bank's.
Arrays, two pointers & sliding window
- Two-Sum on a Sorted ArrayTwo pointerseasyfree
- Three SumTwo pointersmediumfree
- Maximum Points in a Rotating AngleSweep windowmediumfree
- Count Subarrays With Sum Less Than KSliding windowmediumfree
- Longest Subarray With Sum KPrefix + hashmediumfree
- Shortest Subarray with Exactly K Distinct ValuesSliding windowhardfree
- Count Subarrays with Sum in a RangePrefix + structurehardfree
Sorting, searching & order statistics
- Closest Median Profit Between TradersOrder statisticsmediumfree
- Quickselect: Finding the K-th Smallest ElementSelectionmediumfree
- Design a Class with Save and N-th Smallest QueryData-structure designmediumfree
- Bucket Sort for Uniform SamplesLinear-time sortmediumfree
- Second Largest with Minimum ComparisonsComparison boundshardfree
Dynamic programming & recursion
- Maximum Profit from Stock TradesDP / greedyeasyfree
- Edit Distance (Levenshtein Distance)Classic DPmediumfree
- 24 Game SolverBacktrackingmediumfree
- Finding the k-th Hamming NumberDP + pointersmediumfree
- Optimal Fibonacci ComputationMatrix powermediumfree
- K Disjoint Maximum-Sum SubarraysMulti-state DPhardfree
- Longest Increasing Subsequence with ReconstructionDP + binary searchhardfree
Greedy & interval problems
- Minimum Number of Rooms for Interval PartitioningSweep + heapmediumfree
- Interval MergingSort + sweepmediumfree
- Maximum Non-Overlapping Interval SchedulingExchange argumentmediumfree
Graphs & grids
- Counting Friend CirclesUnion-findmediumfree
- Shortest Path on a Grid with Alternating Move DirectionsBFS with statemediumfree
- DAG Reachability Queries with PreprocessingGraph preprocessinghardfree
Streaming & market data
- Top META Trader by Transaction VolumeHash aggregationmediumfree
- Streaming Maximum Drawdown With Rolling WindowMonotonic dequemediumfree
- Streaming Merge Join with Missing KeysTwo-stream mergemediumfree
- Trade-by-Trade Realized P&L Engine With FIFO MatchingEvent processinghardfree
- Streaming Quantile Approximation with T-DigestSketchinghardfree
- Order Book Data Structure and Arbitrage DetectionBook designhardfree
Numerics & strings
- Numerically Stable Log-Sum-Exp and SoftmaxFloating pointmediumfree
- Approximating Zeros of a Continuous FunctionBisectionmediumfree
- Integer Arithmetic on Decimal StringsBig-integer stringsmediumfree
C++/Python internals & class design
- C++ unordered_map Default Value BehaviorC++ semanticseasyfree
- C++: const Pointer DeclarationsC++ semanticseasyfree
- Compiler-Generated Special Member Functions in C++C++ semanticseasyfree
- Python yield and C++ friend/static KeywordsLanguage mixeasyfree
- C++ Class Design: 2D Point with Coordinates and HashingClass designmediumfree
- Design Tic-Tac-ToeClass designmediumfree
The planHow to prepare for coding questions
Five techniques to make reflexive, in the order they pay off. Each maps onto one of the practice groups above, so you can drill it immediately after reading.
- Make the window-vs-prefix decision automatic. Classify the array constraint before typing: monotone (positive entries, distinct counts) means two pointers; exact sums with negatives mean prefix sums in a hash map.
- Rehearse naming DP states out loud. For edit-distance and subsequence variants, practice saying “let \(f(i,j)\) be…” and the transition in one sentence each — interviewers grade the formulation; the code is bookkeeping.
- Carry a small order-statistics toolkit. Quickselect for a one-shot k-th element, a heap for repeated queries, bucket ideas when the input is uniform. Choosing among them — and saying why — is the actual question.
- Practice one-pass discipline on market-shaped input. For streaming problems, state what you keep, why nothing else can matter, and the cost per tick before coding — that narration separates quant-shop loops from generic ones.
- If you target HFT software roles, drill C++ internals separately. const-correctness, map-lookup defaults and compiler-generated special members come as rapid-fire warm-ups — free points if fresh, instant flags if not. Then run the free practice set and take the interactive coding playlist on a clock.
FAQCoding interview questions — frequently asked
How important is coding for quant interviews?
For software-engineering and quant-dev tracks it is the dominant topic — 541 of the 564 coding problems in this set carry a software-engineering role tag, and most SWE loops test it at every stage from online assessment to onsite. Traders and researchers usually see a lighter version: clean scripting and complexity reasoning rather than full algorithm design.
What coding topics should I focus on?
Arrays with two pointers and sliding windows, hash-map prefix-sum tricks, and dynamic programming cover the most ground in this set. Round it out with heap and order-statistics tools, one-pass streaming patterns, and — if you are targeting HFT software roles — rapid-fire C++ internals.
How hard are coding interview questions?
Centered on medium: the 564-problem set splits into 128 easy, 313 medium and 123 hard. The hard tail is mostly composition — two standard ideas chained, or a familiar idea under a streaming constraint — rather than exotic algorithms.
Are these real quant interview questions?
They are representative, not verbatim. The problems are curated from our bank to match the coding shapes candidates report, rewritten for clarity with worked solutions we author ourselves — we never claim any wording is a leaked question.