Capital One software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
Scenario
Part 1 — Card-level authorization
card_id, account_id, and merchant_id. Each card is locked to its configured merchant.id, card_id, merchant_id, amount, and timestamp. Amounts are dollar strings with exactly two decimal places; timestamps are Unix seconds encoded as strings.MERCHANT_LOCK fails when the transaction's merchant differs from its card's configured merchant.MAX_TRANSACTION fails when the amount is strictly greater than 500.00. Exactly 500.00 is allowed.evaluate_part1(cards: list[dict[str, str]], transactions: list[dict[str, str]])The return type is up to the candidate. The examples use a list of decision objects with id, status, and reasons; your representation must convey the same information.Example 1:
{
"cards": [
{"card_id": "c1", "account_id": "a1", "merchant_id": "shop-a"},
{"card_id": "c2", "account_id": "a1", "merchant_id": "shop-b"}
],
"transactions": [
{"id": "t1", "card_id": "c1", "merchant_id": "shop-a", "amount": "200.00", "timestamp": "0"},
{"id": "t2", "card_id": "c1", "merchant_id": "shop-b", "amount": "10.00", "timestamp": "1"},
{"id": "t3", "card_id": "c2", "merchant_id": "shop-b", "amount": "500.00", "timestamp": "2"},
{"id": "t4", "card_id": "c2", "merchant_id": "shop-b", "amount": "500.01", "timestamp": "3"},
{"id": "t5", "card_id": "c1", "merchant_id": "shop-b", "amount": "600.00", "timestamp": "4"}
]
}[
{"id": "t1", "status": "APPROVED", "reasons": []},
{"id": "t2", "status": "DECLINED", "reasons": ["MERCHANT_LOCK"]},
{"id": "t3", "status": "APPROVED", "reasons": []},
{"id": "t4", "status": "DECLINED", "reasons": ["MAX_TRANSACTION"]},
{"id": "t5", "status": "DECLINED", "reasons": ["MAX_TRANSACTION", "MERCHANT_LOCK"]}
]t1 and t3 satisfy both rules, including the inclusive 500.00 boundary. t2 uses the wrong merchant, t4 exceeds the amount limit by 0.01, and t5 fails both rules.Part 2 — Configurable overlapping spending windows
rule_id, scope, entity_id, window_seconds, and limit. Its scope is either card, matching a card_id, or account, matching the card's account_id. Multiple policies with different windows and limits may target the same entity.W, at transaction time t, let S be the sum of previously approved, matching transactions with timestamps in the interval (t - W, t]. Fail that policy exactly when S + current_amount > limit.rule_id in the same sorted reasons list.rule_id. Render snapshot totals with exactly two decimal places.evaluate_part2(cards: list[dict[str, str]], transactions: list[dict[str, str]], policies: list[dict[str, str]])Example 2:
{
"cards": [
{"card_id": "c1", "account_id": "a1", "merchant_id": "shop-a"},
{"card_id": "c2", "account_id": "a1", "merchant_id": "shop-b"}
],
"policies": [
{"rule_id": "CARD_60", "scope": "card", "entity_id": "c1", "window_seconds": "60", "limit": "300.00"},
{"rule_id": "ACCOUNT_120", "scope": "account", "entity_id": "a1", "window_seconds": "120", "limit": "450.00"}
],
"transactions": [
{"id": "p1", "card_id": "c1", "merchant_id": "shop-a", "amount": "200.00", "timestamp": "0"},
{"id": "p2", "card_id": "c2", "merchant_id": "shop-b", "amount": "200.00", "timestamp": "10"},
{"id": "p3", "card_id": "c1", "merchant_id": "shop-a", "amount": "110.00", "timestamp": "20"},
{"id": "p4", "card_id": "c1", "merchant_id": "shop-a", "amount": "50.00", "timestamp": "30"},
{"id": "p5", "card_id": "c1", "merchant_id": "shop-a", "amount": "100.00", "timestamp": "60"}
]
}{
"decisions": [
{"id": "p1", "status": "APPROVED", "reasons": []},
{"id": "p2", "status": "APPROVED", "reasons": []},
{"id": "p3", "status": "DECLINED", "reasons": ["ACCOUNT_120", "CARD_60"]},
{"id": "p4", "status": "APPROVED", "reasons": []},
{"id": "p5", "status": "DECLINED", "reasons": ["ACCOUNT_120"]}
],
"policy_totals": [
{"rule_id": "ACCOUNT_120", "approved_total": "450.00"},
{"rule_id": "CARD_60", "approved_total": "50.00"}
]
}p1 and p2, the account total is 400.00 and c1's total is 200.00. p3 would produce account usage 510.00 > 450.00 and card usage 310.00 > 300.00, so neither policy records it. p4 produces account usage 450.00 and card usage 250.00, so it passes. At time 60, p1 is exactly on the card window's excluded boundary; p5 would produce card usage 50.00 + 100.00 = 150.00, but account usage 450.00 + 100.00 = 550.00, so it fails only ACCOUNT_120. Final totals are therefore 450.00 and 50.00.Example 3:
{
"cards": [
{"card_id": "c1", "account_id": "a1", "merchant_id": "shop-a"},
{"card_id": "c2", "account_id": "a1", "merchant_id": "shop-b"}
],
"policies": [
{"rule_id": "CARD_60", "scope": "card", "entity_id": "c1", "window_seconds": "60", "limit": "300.00"},
{"rule_id": "ACCOUNT_120", "scope": "account", "entity_id": "a1", "window_seconds": "120", "limit": "450.00"}
],
"transactions": [
{"id": "e1", "card_id": "c1", "merchant_id": "shop-a", "amount": "300.00", "timestamp": "0"},
{"id": "e2", "card_id": "c2", "merchant_id": "shop-b", "amount": "150.00", "timestamp": "0"},
{"id": "e3", "card_id": "c1", "merchant_id": "shop-b", "amount": "600.00", "timestamp": "1"},
{"id": "e4", "card_id": "c1", "merchant_id": "shop-a", "amount": "1.00", "timestamp": "60"},
{"id": "e5", "card_id": "c1", "merchant_id": "shop-a", "amount": "300.00", "timestamp": "120"},
{"id": "e6", "card_id": "c2", "merchant_id": "shop-b", "amount": "150.00", "timestamp": "120"}
]
}{
"decisions": [
{"id": "e1", "status": "APPROVED", "reasons": []},
{"id": "e2", "status": "APPROVED", "reasons": []},
{"id": "e3", "status": "DECLINED", "reasons": ["ACCOUNT_120", "CARD_60", "MAX_TRANSACTION", "MERCHANT_LOCK"]},
{"id": "e4", "status": "DECLINED", "reasons": ["ACCOUNT_120"]},
{"id": "e5", "status": "APPROVED", "reasons": []},
{"id": "e6", "status": "APPROVED", "reasons": []}
],
"policy_totals": [
{"rule_id": "ACCOUNT_120", "approved_total": "450.00"},
{"rule_id": "CARD_60", "approved_total": "300.00"}
]
}e1 reaches the card cap exactly; e2, processed next at the same timestamp, reaches the shared account cap exactly. e3 fails four rules: wrong merchant, 600.00 > 500.00, proposed card total 300.00 + 600.00 = 900.00, and proposed account total 450.00 + 600.00 = 1050.00. At time 60, the card total has expired, but e4 still fails because the account would reach 451.00. At time 120, both time-zero purchases leave the account window; e5 and e6 then rebuild its total to 300.00 + 150.00 = 450.00. Only e5 belongs to c1, leaving its total at 300.00.Notes:
(scope, entity_id) pair. Window lengths are 1–86,400 seconds; timestamps are nonnegative; amounts and limits range from 0.01 to 1000000000.00.None for an unknown account.top_active(k) returns up to k account IDs, ordered by decreasing activity count, breaking ties by lexicographically increasing account ID. Accounts with zero activity are included. Return an empty list when k <= 0.n be the current number of accounts and r = min(max(k, 0), n). Support account creation and each transaction in O(log(n + 1)) time, balance lookups in expected O(1) time, and ranking queries in O(r log(r + 1)) time. Maintain O(n) persistent storage, independent of transaction history, with at most O(r) temporary storage per ranking query. Do not sort all accounts on every query or retain stale ranking entries indefinitely. Hash-table accesses may be treated as expected O(1).Function or class signatureBank() — construct an empty bank.create_account(account_id: str) -> booldeposit(account_id: str, amount: int) -> boolwithdraw(account_id: str, amount: int) -> booltransfer(source_id: str, destination_id: str, amount: int) -> boolget_balance(account_id: str) -> int | Nonetop_active(k: int) -> list[str]{
"operations": [
["create_account", "A"],
["create_account", "B"],
["create_account", "C"],
["deposit", "A", 1000],
["transfer", "A", "B", 300],
["withdraw", "B", 100],
["top_active", 3],
["get_balance", "A"],
["get_balance", "B"]
]
}Output[true, true, true, true, true, true, ["A", "B", "C"], 700, 200]Explanation
1000 - 300 = 700 and 300 - 100 = 200 cents.Example 2:Input{
"operations": [
["create_account", "B"],
["create_account", "A"],
["create_account", "A"],
["deposit", "B", 500],
["transfer", "B", "B", 100],
["transfer", "B", "A", 600],
["withdraw", "A", 1],
["deposit", "A", 0],
["top_active", 10],
["transfer", "B", "A", 500],
["withdraw", "A", 500],
["top_active", 2],
["get_balance", "B"],
["get_balance", "missing"],
["top_active", 0]
]
}Output[true, true, false, true, false, false, false, false, ["B", "A"], true, true, ["A", "B"], 0, null, []]Explanation
200000 method calls and 200000 distinct accounts.1 to 32 uppercase English letters or digits; compare them using ordinary lexicographic string order.-10^12 <= amount <= 10^12; nonpositive amounts must be rejected.-200000 <= k <= 200000.undo(transaction_id), which reverses a previously successful transaction exactly once, including its activity increments. Reject an undo if it would make any balance negative. How would you modify the ranking structure to support both increasing and decreasing activity in O(log(n + 1)) time, and what additional transaction history would you need?Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free