Citadel logo

Citadel Hard Interview Questions

11 hard-level practice questions for Citadel technical interviews

Citadel software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer
coding Hard Verified Question #1

1. Visit All Cities


Category: Graph coding problem

Visit All Cities You are given a list of airline tickets where each ticket represents a directed edge from a departure airport to an arrival...

Input: Graph (nodes and edges)
Output: Computed result
Want to practise this one?
Create a free account to open the full question and practise Citadel questions with AI.
Sign up free
coding Hard Verified Question #2

2. Subsequence Goodness Values


Category: Array coding problem

Subsequence Goodness Values

Input: Array
Output: Integer
coding Hard Verified Question #3

3. Pandigital Addition Count


Category: Algorithm coding problem

Pandigital Addition Count

Input: Integer(s)
Output: Computed result
coding Hard Verified Question #4

4. Flight Itinerary Planner


Category: Graph coding problem

Flight Itinerary Planner

Input: Graph (nodes and edges)
Output: Computed result
coding Hard Verified Question #5

5. Process Schedule Counter


Category: Algorithm coding problem

Process Schedule Counter

Input: List
Output: Integer
coding Hard binary search #1

1. [AI Enabled Coding] Market-Data Server Upgrade Planner


Scenario
Citadel infrastructure engineers need to schedule upgrades for two servers supporting a market-data processing workflow without interrupting their scheduled request handling. A shared deployment worker can upgrade only one server per second, and upgrades may be paused and resumed. This exercise adapts the reported Citadel minimum-server-upgrade-time question; the blackout-policy extension is an additional interview requirement, not a claim about Citadel's internal implementation. You may use an AI assistant while coding, but must explain and validate the resulting algorithm.
Part 1 — Earliest safe completion
  • Each input record has string fields kind, server, seconds, and request_interval. In this part, kind is always "upgrade" and server is either "A" or "B".

  • Sum seconds across records for each server. Records requesting "0" seconds add no work. Every record for the same server has the same positive request_interval.

  • Time consists of integer seconds beginning at 1. A server with interval d handles requests at seconds d, 2d, 3d, ... and cannot be upgraded during those seconds. An upgrade second outside those multiples completes exactly one second of work.

  • The deployment worker can upgrade at most one server in each second. Work is preemptible, there are no dependencies between records, and idle seconds are allowed.

  • Return the smallest nonnegative elapsed time T in which all work can finish. Return an impossible result if no finite schedule exists. If neither server needs work, the answer is 0.

  • Do not construct or simulate a second-by-second schedule. Target O(n + log U) time for this part, where U is the eventual search bound.


Function signature: plan_upgrades(records: list[dict[str, str]])
The return type is up to you. The examples use a JSON integer, or null for impossible.
Example 1:
Input:
[
  {"kind":"upgrade","server":"A","seconds":"2","request_interval":"2"},
  {"kind":"upgrade","server":"A","seconds":"1","request_interval":"2"},
  {"kind":"upgrade","server":"B","seconds":"1","request_interval":"3"},
  {"kind":"upgrade","server":"B","seconds":"0","request_interval":"3"}
]

Output:
5

Explanation: A needs 2 + 1 = 3 seconds and B needs 1 + 0 = 1. By time 4, A has only seconds 1 and 3 available. By time 5, assign A seconds 1, 3, and 5, and B second 2, so the minimum is 5.
Part 2 — Blackout policies from multiple infrastructure teams
Other teams now submit deployment blackouts. Extend the planner to accept records with string fields kind: "blackout", source, start, and end, alongside all existing upgrade records.
  • A blackout forbids the deployment worker from upgrading either server during the inclusive interval [start, end]. Normal request-interval restrictions still apply.

  • Combine blackouts from every source by set union: overlapping or adjacent windows must not double-count blocked seconds. The source is an audit label, not a priority, and duplicate windows have no additional effect.

  • Keep the implementation flexible enough for future policy sources that contribute additional finite blackout windows. Separate record ingestion, blackout normalization, and scheduling feasibility rather than hard-coding source names.

  • Before implementing, discuss how your return type changes to include diagnostic information. The canonical output below contains minimum_seconds, capacity, shared_capacity, and blackout_seconds.

  • At the minimum time T, capacity[server] counts seconds in [1, T] that are individually usable by that server, regardless of how much work it needs. shared_capacity counts seconds usable by at least one server, counting each second once. blackout_seconds counts the union of blackout seconds in [1, T], including seconds that were already unavailable due to request handling. Capacities describe opportunities, not an actual allocation.

  • For an impossible result, all four output fields are null. For T = 0, both server capacities and both other counts are 0.

  • Do not iterate through the timeline. Target O(n log n + log U · log(n + 1)) time and O(n) space, including diagnostics.


Example 2:
Input:
[
  {"kind":"upgrade","server":"A","seconds":"2","request_interval":"2"},
  {"kind":"upgrade","server":"A","seconds":"1","request_interval":"2"},
  {"kind":"upgrade","server":"B","seconds":"1","request_interval":"3"},
  {"kind":"upgrade","server":"B","seconds":"0","request_interval":"3"},
  {"kind":"blackout","source":"exchange_freeze","start":"2","end":"3"}
]

Output:
{
  "minimum_seconds":7,
  "capacity":{"A":3,"B":4},
  "shared_capacity":4,
  "blackout_seconds":2
}

Explanation: Work totals remain A = 3 and B = 1. By time 7, A has 7 - floor(7/2) = 4 request-safe seconds; blackout second 3 removes one, leaving {1,5,7}. B has 7 - floor(7/3) = 5 request-safe seconds; blackout second 2 removes one, leaving {1,4,5,7}. Before blackouts, the shared capacity is 7 - floor(7/6) = 6; removing seconds 2 and 3 leaves 4. A can use 1, 5, and 7 while B uses 4. At time 6, A has only two usable seconds, so 7 is minimal. The blackout union contains 2 seconds.
Example 3:
Input:
[
  {"kind":"upgrade","server":"A","seconds":"2","request_interval":"2"},
  {"kind":"upgrade","server":"A","seconds":"1","request_interval":"2"},
  {"kind":"upgrade","server":"B","seconds":"1","request_interval":"3"},
  {"kind":"upgrade","server":"B","seconds":"0","request_interval":"3"},
  {"kind":"blackout","source":"exchange_freeze","start":"2","end":"4"},
  {"kind":"blackout","source":"risk_validation","start":"3","end":"6"}
]

Output:
{
  "minimum_seconds":9,
  "capacity":{"A":3,"B":3},
  "shared_capacity":4,
  "blackout_seconds":5
}

Explanation: The blackout union is [2,6], containing 6 - 2 + 1 = 5 seconds, not 3 + 4 = 7. A's raw capacity is 9 - floor(9/2) = 5; blackout seconds 3 and 5 reduce it to {1,7,9}, or 3. B's raw capacity is 9 - floor(9/3) = 6; blackout seconds 2, 4, and 5 reduce it to {1,7,8}, or 3. The raw shared capacity is 9 - floor(9/6) = 8; only four blackout seconds, 2 through 5, were in that shared capacity, so the result is 4. Second 6 violates both servers' request rules and a blackout rule, but must not be subtracted twice. Assign A seconds 1, 7, and 9 and B second 8. At time 8, A has only two usable seconds, proving minimality.
Notes:
  • There are at most 200,000 records, including at least one upgrade record per server. Intervals are between 1 and 1,000,000,000; total requested work is at most 10^18; blackout endpoints satisfy 1 <= start <= end <= 10^18.

  • Inputs satisfy the stated schemas and consistency requirements. All numeric input values are decimal strings; use exact integer arithmetic and guard against overflow in languages with fixed-width integers.

  • Blackouts are finite, upgrades have no switching cost, and the two servers are the only consumers of the deployment worker.
Want to practise this one?
Create a free account to open the full question and practise Citadel questions with AI.
Sign up free
coding Hard concurrency #2

2. Concurrency — Optimize a function for concurrency

Background: In high-frequency trading systems at Citadel, optimizing for concurrency is crucial to maximize throughput and minimize latency. When managing trades and market data, optimizing access and updates to shared resources is essential.
Problem statement: You need to design a function optimizeConcurrency that takes a list of trades to process concurrently. Each trade requires an update to a shared orderBook, but the updates should not conflict. Use appropriate data structures to minimize locking and waiting.
Function/class signature:
  • def optimizeConcurrency(trades: List[Dict[str, int]]) -> List[Optional[int]]:

  • def updateOrderBook(trade: Dict[str, int]) -> None:


Example 1:
  • Input: trades = [{'id':1, 'amount':100}, {'id':2, 'amount':200}, {'id':1, 'amount':150}]

  • Output: None

  • Explanation: The function should process trades concurrently and reflect the latest amount for each unique trade ID in the order book without conflicts.


Example 2:
  • Input: trades = [{'id':3, 'amount':300}, {'id':4, 'amount':400}]

  • Output: None

  • Explanation: Similar processing for these trades, ensuring each update is atomic and thread-safe.


Constraints:
  • 1 <= trades.length <= 1000

  • Trade IDs are between 1 and 10000.

  • The function should handle up to 100 concurrent updates.
coding Hard concurrency #3

3. CODING — Optimize for Concurrency in an Order Book

Background: Citadel's trading strategies depend on efficient order book management. An in-memory order book allows traders to process orders quickly and adjust to market conditions dynamically.
Problem statement: You are tasked with optimizing a function that handles buy and sell orders in a thread-safe manner. You should implement a class that supports concurrent access while ensuring that orders are processed correctly. The order book allows for adding and removing orders and retrieving the current best buy and sell prices. The key requirements involve handling multiple threads without introducing race conditions.
Function/class signature:
  • class OrderBook

  • def add_order(self, order_id: str, price: float, quantity: int, order_type: str) -> None:

  • def remove_order(self, order_id: str) -> None:

  • def get_best_buy(self) -> Tuple[float, int]:

  • def get_best_sell(self) -> Tuple[float, int]:

Example 1:
  • Input: add_order('1', 100.0, 10, 'buy')

  • Output: None

  • Explanation: A buy order with ID '1' for 10 units at $100 is added.

Example 2:
  • Input: add_order('2', 105.0, 5, 'sell')

  • Output: None

  • Explanation: A sell order with ID '2' for 5 units at $105 is added. Now, get_best_buy() should return (100.0, 10) and get_best_sell() should return (105.0, 5).

Constraints:
  • 1 <= order_id <= 10^5

  • Price and quantity are non-negative floats and integers respectively.

  • Concurrent calls to add_order and remove_order may occur, but please ensure consistency in retrieval methods.
coding Hard graph #4

4. Graph — Find the shortest path in a trading network

Background: Citadel relies on efficient trading algorithms to quickly make transactions across different markets. Understanding the shortest routes between various venues can optimize trade execution.
Problem statement: In a network of trading venues represented as a directed graph, where each edge represents the time taken to execute a trade between two venues, your task is to find the shortest time to get from a source venue to a target venue. Implement Dijkstra's algorithm to determine the minimum execution time.
Function/class signature:
  • def shortest_time(venues: List[Tuple[int, int, int]], source: int, target: int) -> int:

Example 1:
  • Input: venues = [(0, 1, 5), (0, 2, 10), (1, 2, 2), (2, 3, 1)], source = 0, target = 3

  • Output: 8

  • Explanation: The shortest path is from 0 -> 1 -> 2 -> 3 with a total time of 5 + 2 + 1 = 8.

Example 2:
  • Input: venues = [(0, 1, 8), (1, 3, 6), (0, 2, 7), (2, 3, 2)], source = 0, target = 3

  • Output: 9

  • Explanation: The optimal path is 0 -> 2 -> 3 with a total time of 7 + 2 = 9.

Constraints:
  • 1 <= len(venues) <= 1000

  • 0 <= venue index < 100

  • Execution time is positive integer and does not exceed 1000.
coding Hard graph #5

5. Graph — Shortest Path in a Weighted Graph

Background: Citadel often deals with financial algorithms that require efficient pathfinding through complex market data represented as graphs. This problem is crucial for optimizing trade routes.
Problem statement: Given a weighted directed graph represented as an adjacency list, your task is to implement a function that calculates the shortest path from a source node to a target node using Dijkstra’s algorithm. Each edge weight represents the cost for trading between nodes, and you need to return the minimum trading cost.
Function/class signature:
  • def shortest_path(graph: Dict[int, List[Tuple[int, float]]], source: int, target: int) -> float:


Example 1:
Input: graph = {0: [(1, 2.0), (2, 4.0)], 1: [(2, 1.0)], 2: []}
Output: 3.0
Explanation: The shortest path from node 0 to node 2 is via node 1 with a total cost of 2.0 + 1.0 = 3.0.
Example 2:
Input: graph = {0: [(1, 10.0)], 1: [(2, 5.0)], 2: [(3, 1.0)], 3: []}
Output: 16.0
Explanation: The shortest path is from 0 to 1 to 2 to 3 with total cost 10.0 + 5.0 + 1.0 = 16.0.
Constraints:
  • 1 <= len(graph) <= 100

  • 0 <= source, target < len(graph)

  • weights are positive doubles.
system design Hard graph #6

6. Design CurrencyConverter — consistent in-memory currency conversion


Background
Citadel's portfolio and risk workflows need to express monetary exposures in a common reporting currency, even when a direct exchange rate is unavailable. Design an in-memory conversion class for one fixed exchange-rate snapshot. This adapts a reported Citadel currency-conversion interview question; consistency checking and incremental insertion are explicit extensions for this exercise, not claims about Citadel's internal implementation.
Requirements
1. add_rate(base, quote, rate) proposes the relationship 1 unit of base = rate units of quote. Accepted relationships support reciprocal and transitive conversions. Rates are synthetic inputs, not executable market quotes; ignore spreads, fees, timestamps, and rounding to currency minor units.
2. If the currencies are already connected, accept the proposal only when abs(rate - implied_rate) <= 1e-9 * max(rate, implied_rate). Return true for a consistent proposal but retain the existing implied relationships. Return false for an inconsistent proposal, without adding any currencies or changing any implied relationships.
3. A valid relationship between disconnected currencies is accepted. A same-currency proposal has an implied rate of exactly 1.0, even if that currency is unknown: a consistent proposal registers the currency, while an inconsistent one does not.
4. get_rate and convert return null when either currency is unknown or the currencies are disconnected. A known currency converts to itself at rate 1.0; an unknown currency does not. Conversion is linear: converted_amount = amount * implied_rate.
5. Currency identifiers must be exactly three uppercase ASCII letters. Rates must be finite and strictly positive; amounts must be finite and nonnegative. Invalid arguments raise ValueError, and invalid insertions must not change the book. Validate all arguments before checking connectivity.
6. Support a large sequence of insertions and queries without traversing every stored relationship on each call. The class represents a consistent snapshot: replacing existing rates, deleting rates, arbitrage optimization, and concurrent access are out of scope.
Class API
  • CurrencyConverter() — construct an empty book.

  • add_rate(base: str, quote: str, rate: float) -> bool — accept or reject a proposed relationship according to the rules above.

  • get_rate(base: str, quote: str) -> Optional[float] — return the implied quote units per base unit, or None if unavailable.

  • convert(base: str, quote: str, amount: float) -> Optional[float] — convert an amount, or return None if unavailable.

  • currencies() -> List[str] — return all registered identifiers in ascending lexicographic order.


Example 1:
Input sequence:
[
  ["add_rate", "USD", "EUR", 0.8],
  ["add_rate", "EUR", "JPY", 150.0],
  ["get_rate", "USD", "JPY"],
  ["convert", "JPY", "USD", 24000.0],
  ["add_rate", "USD", "JPY", 121.0],
  ["get_rate", "USD", "JPY"],
  ["currencies"]
]

Output:
[true, true, 120.0, 200.0, false, 120.0, ["EUR", "JPY", "USD"]]

Explanation: One USD converts to 0.8 * 150 = 120 JPY, so 24000 / 120 = 200 USD. The proposed rate of 121 contradicts the established snapshot and is rejected.
Example 2:
Input sequence on a new instance:
[
  ["get_rate", "USD", "USD"],
  ["add_rate", "CHF", "CHF", 2.0],
  ["currencies"],
  ["add_rate", "USD", "EUR", 0.5],
  ["add_rate", "GBP", "JPY", 4.0],
  ["convert", "USD", "JPY", 10.0],
  ["add_rate", "EUR", "GBP", 2.0],
  ["convert", "USD", "JPY", 10.0],
  ["add_rate", "CHF", "CHF", 1.0],
  ["convert", "CHF", "CHF", 7.0]
]

Output:
[null, false, [], true, true, null, true, 40.0, true, 7.0]

Explanation: The rejected CHF relationship must not register CHF. Initially USD and JPY are disconnected. After bridging EUR to GBP, one USD equals 0.5 * 2 * 4 = 4 JPY, so ten USD converts to 40 JPY. Registering CHF with a self-rate of 1 permits identity conversion.
Constraints
  • At most 17,576 distinct currencies and 200,000 total calls; access is single-threaded.

  • Inputs are strings and real numeric values, excluding booleans. Amounts are at most 1e12; proposed rates and all implied ratios remain between 1e-12 and 1e12.

  • Use double-precision arithmetic. Example numeric outputs and conversion tests are compared with relative tolerance 1e-9 and absolute tolerance 1e-9; proposal acceptance uses only the relative formula specified above.

  • Aim for amortized near-constant insertion and conversion time, excluding the explicitly sorted currencies() method.

Start practicing Citadel questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free