25 quant programming and algorithms interview questions with answers
25 original quant programming interview questions with explained answers on algorithms, Python, data structures, numerical accuracy and reproducibility.
How to approach these questions
A quant implementation needs a clear contract: correct outputs, controlled numerical error and suitable performance on the intended workload. These examples combine algorithmic reasoning with Python behaviour, streaming calculations and numerical methods. State the input and data-structure assumptions whenever you give a complexity bound; expected, amortised and worst-case costs are different claims.
Define correctness first
Clarify duplicate handling, index conventions, empty inputs and required precision. A fast implementation of an ambiguous contract is difficult to evaluate.
Count operations and memory
Explain which elements are visited and what state is retained. Include preprocessing and auxiliary space instead of quoting a complexity label alone.
Treat numerics as part of correctness
Floating-point representation, convergence conditions and random-number generation affect the result. Use stable formulations and record enough context to reproduce a simulation.
Sample questions, answers and explanations
Try each question before reading its answer. These original teaching examples remain free to read on this page.
Search, hashing and sorting
Attach each complexity claim to its access pattern and assumptions.
A sorted random-access array contains n elements. What is binary search's worst-case comparison complexity?
Answer: O(log n).
Explanation: Each comparison discards about half the remaining interval. The random-access assumption matters when translating the method to another data structure.
Answer: Records with equal sort keys retain their relative input order.
Explanation: Stability matters when prior ordering carries information or when performing several sorting passes. It is separate from speed and memory use.
Data structures for common tasks
Choose state that avoids repeated work while preserving the required output order.
Why might an O(n²) algorithm beat an O(n log n) algorithm on a very small input?
Answer: Constant factors, setup cost and memory access can dominate at small n.
Explanation: Asymptotic notation describes growth, not a stopwatch result for every input. Benchmark the realistic workload after checking correctness.
Two workers read a counter, increment locally and write it back. What can go wrong?
Answer: An update can be lost because both workers read the same old value.
Explanation: The read-modify-write sequence needs synchronisation or an atomic operation. Independent-looking instructions do not make the sequence atomic.
Before optimising a pricing routine, what should you clarify?
Answer: Required accuracy, valid inputs, error behaviour, workload and latency or throughput objective.
Explanation: Optimisation needs a measurable target and correctness boundary. A faster routine with uncontrolled numerical error does not satisfy a pricing contract.
67 programming/algorithms questions from the bank
Each question has its own page with a short answer and a credit to its source. Hints and full worked solutions are in the question bank with a free account.
Our bank summary dated contains 69 Programming/Algorithms entries in the bank. Counts describe entries in our curated practice bank, including its source and classification choices. They do not measure employer interview frequency, candidate success rates or how often any one question is asked.
C++: 31 entries, or 44.9% of this topic's bank. Use this coverage to identify areas for practice alongside the technique-based examples above.
Algorithms: 18 entries, or 26.1% of this topic's bank. Use this coverage to identify areas for practice alongside the technique-based examples above.
Numerical Methods: 11 entries, or 15.9% of this topic's bank. Use this coverage to identify areas for practice alongside the technique-based examples above.
The public examples above were written for these guides. They illustrate the techniques and are not a reproduction or ranking of the bank's sourced questions. The dashboard's broader bank combines sourced questions, worked answers where available and references for book entries without a reproduced solution.
Subtopic coverage in the bank
Subtopic
Bank entries
C++
31
Algorithms
18
Numerical Methods
11
Sorting & Searching
6
Data Structures
2
Dynamic Programming
1
Bank difficulty labels: 49 easy · 20 medium.
Lessons behind the techniques
Use these lesson previews to find the definitions and derivations behind the worked examples.