Banking System with Top Activity
Reported by candidates from Capital One's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt at this Capital One banking OA, reported in September 2026, is treating balance and activity as the same number. They aren't. Deposits move both, transfers move balance in opposite directions but push activity up on both accounts, and failed operations touch neither. It's a design-style simulation problem: a hash map of accounts, four operations, and a ranked TOP_ACTIVITY query with an alphabetical tie-break. Nothing exotic, but one wrong update and your output array drifts from the expected one. If you blank mid-assessment, StealthCoder can run invisibly as a safety net.
The problem
Implement a banking system that processes a sequence of operations. Initially, the system contains no accounts. Each account has a balance and a financial-activity total, both starting at zero. Each row of operations has one of these forms: ["CREATE_ACCOUNT", accountId]: If the account already exists, return false. Otherwise, create it and return true. ["DEPOSIT", accountId, amount]: If the account does not exist, return -1. Otherwise, add amount to its balance and activity, then return its updated balance. ["TRANSFER", fromAccountId, toAccountId, amount]: Return -1 if either account does not exist, both identifiers name the same account, or the sender has insufficient funds. Otherwise, move amount from the sender to the recipient, add amount to both accounts' activity, and return the sender's updated balance. ["TOP_ACTIVITY", n]: Return up to n account descriptions formatted as accountId(activity). Order them by activity from highest to lowest, breaking ties by accountId in ascending alphabetical order. If fewer than n accounts exist, return all accounts in that order. An account's financial activity is the absolute sum of amounts from its successful deposits and transfers. A successful transfer contributes its amount to the activity of both endpoints. Unsuccessful transactions do not contribute activity. Return one string array for every operation, in the same order. A scalar result is represented as a one-element array, such as ["true"] or ["2700"]; a TOP_ACTIVITY result contains its ranked account descriptions directly. What the interview report shared The report gave all four operation rules, the activity-ranking rule, and a complete operation/output sequence. This practice version is an estimated 95% match to that core task; the report did not include numeric limits or the original method and parameter names, so those details are not presented as source-provided. Function processBankingOperations(operations: String[][]) → String[][] Examples Example 1 operations = [["CREATE_ACCOUNT","account1"],["CREATE_ACCOUNT","account1"],["CREATE_ACCOUNT","account2"],["DEPOSIT","non-existing","2700"],["DEPOSIT","account1","2700"],["TRANSFER","account1","account2","2701"],["TRANSFER","account1","account2","200"],["TRANSFER","account1","account2","2500"],["DEPOSIT","account2","300"],["CREATE_ACCOUNT","account3"],["DEPOSIT","account3","4000"],["TOP_ACTIVITY","3"],["DEPOSIT","account2","1000"],["TOP_ACTIVITY","2"],["TOP_ACTIVITY","5"]] return = [["true"],["false"],["true"],["-1"],["2700"],["-1"],["2500"],["0"],["3000"],["true"],["4000"],["account1(5400)","account3(4000)","account2(3000)"],["4000"],["account1(5400)","account2(4000)"],["account1(5400)","account2(4000)","account3(4000)"]] The first deposit gives account1 a balance and activity of 2700. The transfer of 2701 fails, while the transfers of 200 and 2500 succeed, leaving account1 with balance 0 and activity 5400. Those transfers give account2 activity 2700; after its deposit of 300, its balance and activity are 3000. With account3's deposit of 4000, the first ranking is therefore account1(5400), account3(4000), account2(3000). After another deposit of 1000 into account2, accounts 2 and 3 both have activity 4000. Their tie is resolved alphabetically, so account2 comes first.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The structure is a map from accountId to a pair of numbers: balance and activity. CREATE_ACCOUNT checks existence. DEPOSIT adds to both fields. TRANSFER validates three things first: both accounts exist, they're different, and the sender has enough funds. Only then do you subtract from the sender's balance, add to the recipient's balance, and add the amount to both activities. TOP_ACTIVITY sorts all accounts by activity descending, then accountId ascending, and takes the first n. Sorting on each call is fine unless the limits say otherwise, and the report gave none. Pitfalls: returning the recipient's balance from TRANSFER instead of the sender's, wrapping scalar results as one-element string arrays, parsing amounts from strings, and reversing the tie-break. Check example 1 by hand. If you freeze live, StealthCoder is the hedge that reads the prompt and hands you the structure.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Banking System with Top Activity cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Capital One's OA.
Capital One reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Banking System with Top Activity FAQ
What's the trick in the Capital One Banking System with Top Activity problem?+
Track two separate numbers per account, balance and activity. Deposits raise both. Successful transfers lower the sender's balance, raise the recipient's balance, and raise both activities by the amount. Failed operations change nothing. Keep them in one map keyed by accountId.
How hard is this OA really?+
It's more careful than hard. There's no clever algorithm, just a hash map, validation order, and a custom sort. Most failures come from small slips like the wrong return value on TRANSFER or a flipped tie-break, not from the concept.
How should TOP_ACTIVITY be sorted?+
Sort by activity descending, and when activities match, by accountId ascending as a string. Take the first n, or all accounts if fewer exist. Format each as accountId(activity). Example 1 shows account2 beating account3 at a 4000 tie.
What makes a TRANSFER fail?+
Three cases return -1: either account doesn't exist, the sender and recipient are the same account, or the sender's balance is below the amount. Check all three before changing anything, so a failed transfer adds no activity to either account.
How do I prepare for this in 48 hours?+
Write the account map and four handlers from scratch, then run example 1 by hand and compare every output. Practice returning every result as a string array. Test edge cases: self-transfer, exact-balance transfer, n larger than the account count, and ties.