Citadel logo

Citadel Software Engineer System Design Questions

26 practice questions for Citadel Software Engineer 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

No verified questions yet for Citadel.

system design Hard graph #1

1. 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.
Want to practise this one?
Create a free account to open the full question and practise Citadel questions with AI.
Sign up free

Related Citadel Software Engineer interview prep

Start practicing Citadel questions

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

Get Started Free