Coding Interview Questions
Coding interviews at quant and HFT shops test the same data-structures-and-algorithms core as any SWE loop, but with a twist: they prize clean reasoning about complexity, numerical stability, and streaming/online computation, and they love dressing problems in market clothing (order books, VWAP, dra
How to think about coding questions
The coding problems here aren't about syntax — they're about choosing the right structure before you type. Nearly every one comes down to spotting the pattern (search, recurrence, greedy choice) that turns an exponential brute force into something that runs.
REMEMBER, DON'T RECOMPUTE
When a problem's pieces overlap, dynamic programming caches subproblem answers so each is solved once — the difference between an exponential recursion and a polynomial table. The whole craft is naming the right state and the transition between states.
PICK THE RIGHT TOOL
Sorting, hashing, two pointers, a heap, binary search on the answer — each collapses a class of problems from O(n²) to O(n log n) or better. Recognizing which invariant the problem hands you (monotonicity, a bound, a structure) is what selects the tool.
The recurring move: before coding, find the structure — the overlapping subproblem, the monotone invariant — that makes the obvious brute force unnecessary.
Coding questions (111)
- Two-Sum on a Sorted Array
- Reverse Words in a String
- Bellman-Ford: Shortest Paths with Negative Edge Weights
- Longest Subarray With Sum at Most K
- Stock Price Previous Lower Day Lookup
- Longest Substring Without Repeating Characters
- Dijkstra's Algorithm with Binary Heap
- Generate All Permutations
- Longest Substring with at Most K Distinct Characters
- Integer Cube Root
- Merge Sort: Correctness and Complexity
- Hash Table Implementation and Collision Resolution
- Number of Islands in a Grid
- Approximating Zeros of a Continuous Function
- Sieve of Eratosthenes: Find All Primes up to N
- Univalued Binary Tree
- Search in a Sorted Matrix
- Edit Distance (Levenshtein Distance)
- The Master Theorem
- Merging Overlapping Intervals
- C++ Vector Reallocation Overhead
- Buy and Sell Stocks with Exact Timing
- Implement Quicksort
- C++ Unique Pointer with Custom Deleters
- Sorting Algorithms: Speed, In-Place, and Structural Assumptions
- Trie Prefix Search Implementation
- Mutable Default Arguments in Python
- Reverse a Linked List and Implement Square Root
- Fast Exponentiation by Squaring
- Python Generators
- Three Sum
- Most Traded Stocks by Volume
- Currency Arbitrage Detection in Exchange Rate Graphs
- Split Array to Minimize the Largest Subarray Sum
- Minimum Window Substring
- Shortest Path with at Most K Bad Edges
- 2D Peak Finding in a Matrix
- Palindrome Pairs
- Critical Path Scheduling on a DAG
- Quickselect: Finding the K-th Smallest Element
- Count Subarrays Divisible by m
- Maximum Profit with Two Transactions
- Find All Bridge Edges in an Undirected Graph
- Online Mean, Variance, and Covariance in O(1)
- Trapping Rain Water
- Search in Rotated Sorted Array
- Numerically Stable Log-Sum-Exp and Softmax
- Maximum Product Subarray
- Inorder Successor in a Binary Search Tree
- Largest Rectangle in Histogram
- Longest Common Subsequence
- Counting Inversions via Modified Merge Sort
- Median from a Data Stream
- Solving the Sliding Puzzle with A* Search
- First Missing Positive in O(n) Time and O(1) Space
- LRU Cache
- Minimum Coin Change
- Maximum Non-Overlapping Interval Scheduling
- Sliding Window Maximum and Minimum with Monotone Deques
- Word Break II
- Weighted Interval Scheduling
- Sliding Window Median Data Structure
- Generate All Permutations and Combinations
- Longest Increasing Subsequence
- LFU Cache
- Add Two Numbers (Linked List)
- Optimal Worker-Task Assignment
- K-Way Merge with a Min-Heap
- 0/1 Knapsack via Dynamic Programming
- 24 Game Solver
- Streaming Majority Element in O(1) Space
- Heap Operations and K Largest Elements
- Minimum Cost Path with Quadratic Travel Cost
- Maximum Drawdown and Recovery Time
- Queue with O(1) Get-Max
- Linear Interpolation from Sorted Pairs
- Wildcard Pattern Matching
- Union-Find with Path Compression and Union by Rank
- Linear Recurrence via Matrix Exponentiation
- Top-K Portfolio Selection with Stability Constraint
- Trade-to-Quote As-Of Join
- Segment Tree with Lazy Propagation for Range Add and Range Min
- Order Management System with Price-Time Priority Matching
- Fixed-Size Memory Pool Allocator
- Maximum Product Partition
- Binary Tree Height, Balance, and Traversal Complexity
- Aho-Corasick Multiple-Pattern Matching
- Minimum Folds to Resize a Paper Sheet
- Random Number Generator Without Replacement
- Knapsack-Style Stock Investment
- Russian Doll Envelopes (2D LIS)
- Average Stock Holding Time
- Maximum Energy Matrix Traversal
- Parallel Machine Scheduling: Minimizing Makespan
- Median of Two Sorted Arrays
- Reservoir Sampling from an Unknown-Length Stream
- Misra-Gries Heavy Hitters Algorithm
- Maximum P&L With At Most K Trades
- C++ Rule of Five: Buffer Lifetime, Moves, and Vector Growth
- Estimating Distinct Elements with HyperLogLog
- Order-Statistics Tree
- Automated Trading System Architecture
- Union Area of Axis-Aligned Rectangles
- Approximate Heavy-Hitters via Count-Min Sketch
- Market Data System Design
- Hopcroft-Karp Maximum Bipartite Matching
- Trade-by-Trade Realized P&L Engine With FIFO Matching
- Knuth-Morris-Pratt Pattern Search
- Alias Method for Fast Discrete Sampling
- Streaming Approximate Quantiles with Rank-Error Guarantees
- Kruskal's MST with Union-Find
Coding interview questions FAQ
What kind of coding questions show up in quant interviews?
This page collects 111 coding problems that recur in quant trading and research interviews, each with a full worked solution and the intuition behind it. They range from quick warmups to the harder variants firms use to separate candidates.
How hard are coding interview questions?
The set spans 13 easy, 68 medium and 30 hard problems. Most sit at medium difficulty — a few minutes of clean reasoning — with a harder tail that rewards knowing the canonical approach rather than grinding.
How should I practice coding for quant interviews?
Work through them by difficulty, starting just below your level, and write the solution out before checking. 9 are free to open with the full worked solution, so you can judge the quality first. Focus on the recurring patterns rather than memorizing answers — the same handful of ideas generate most variants.
Are these real quant interview questions?
They are a curated set drawn from our problem bank — the kind of coding question that actually appears in quant interviews, rewritten for clarity with solutions we author ourselves. We don't claim any single wording is verbatim, and every problem carries a full solution.