Citadel software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
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)Subsequence Goodness Values
Input: ArrayPandigital Addition Count
Input: Integer(s)Flight Itinerary Planner
Input: Graph (nodes and edges)Process Schedule Counter
Input: Listkind, server, seconds, and request_interval. In this part, kind is always "upgrade" and server is either "A" or "B".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.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.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.O(n + log U) time for this part, where U is the eventual search bound.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:[
{"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"}
]5
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 teamskind: "blackout", source, start, and end, alongside all existing upgrade records.[start, end]. Normal request-interval restrictions still apply.source is an audit label, not a priority, and duplicate windows have no additional effect.minimum_seconds, capacity, shared_capacity, and blackout_seconds.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.null. For T = 0, both server capacities and both other counts are 0.O(n log n + log U · log(n + 1)) time and O(n) space, including diagnostics.[
{"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"}
]{
"minimum_seconds":7,
"capacity":{"A":3,"B":4},
"shared_capacity":4,
"blackout_seconds":2
}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:[
{"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"}
]{
"minimum_seconds":9,
"capacity":{"A":3,"B":3},
"shared_capacity":4,
"blackout_seconds":5
}[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:1 <= start <= end <= 10^18.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.def optimizeConcurrency(trades: List[Dict[str, int]]) -> List[Optional[int]]: def updateOrderBook(trade: Dict[str, int]) -> None: trades = [{'id':1, 'amount':100}, {'id':2, 'amount':200}, {'id':1, 'amount':150}] None trades = [{'id':3, 'amount':300}, {'id':4, 'amount':400}] None 1 <= trades.length <= 1000 1 and 10000.100 concurrent updates.class OrderBookdef 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]:add_order('1', 100.0, 10, 'buy')Noneadd_order('2', 105.0, 5, 'sell')Noneget_best_buy() should return (100.0, 10) and get_best_sell() should return (105.0, 5).1 <= order_id <= 10^5add_order and remove_order may occur, but please ensure consistency in retrieval methods.def shortest_time(venues: List[Tuple[int, int, int]], source: int, target: int) -> int:venues = [(0, 1, 5), (0, 2, 10), (1, 2, 2), (2, 3, 1)], source = 0, target = 3 8 0 -> 1 -> 2 -> 3 with a total time of 5 + 2 + 1 = 8.venues = [(0, 1, 8), (1, 3, 6), (0, 2, 7), (2, 3, 2)], source = 0, target = 3 9 0 -> 2 -> 3 with a total time of 7 + 2 = 9.1 <= len(venues) <= 1000 0 <= venue index < 100 def shortest_path(graph: Dict[int, List[Tuple[int, float]]], source: int, target: int) -> float:graph = {0: [(1, 2.0), (2, 4.0)], 1: [(2, 1.0)], 2: []} 3.0 graph = {0: [(1, 10.0)], 1: [(2, 5.0)], 2: [(3, 1.0)], 3: []} 16.0 1 <= len(graph) <= 1000 <= source, target < len(graph) 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.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.1.0, even if that currency is unknown: a consistent proposal registers the currency, while an inconsistent one does not.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.ValueError, and invalid insertions must not change the book. Validate all arguments before checking connectivity.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.[ ["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"] ]
[true, true, 120.0, 200.0, false, 120.0, ["EUR", "JPY", "USD"]]
0.8 * 150 = 120 JPY, so 24000 / 120 = 200 USD. The proposed rate of 121 contradicts the established snapshot and is rejected.Example 2:[ ["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] ]
[null, false, [], true, true, null, true, 40.0, true, 7.0]
0.5 * 2 * 4 = 4 JPY, so ten USD converts to 40 JPY. Registering CHF with a self-rate of 1 permits identity conversion.Constraints1e12; proposed rates and all implied ratios remain between 1e-12 and 1e12.1e-9 and absolute tolerance 1e-9; proposal acceptance uses only the relative formula specified above.currencies() method.Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free