As reported: Okta Staff Software Engineer (May 2026), first round of a parallel Staff loop with another Okta team: an extension of LeetCode 2043 (Simple Bank System) with concurrency added — compare-and-set style operations such as
map.replace(old, new).
This is LeetCode 2043 — Simple Bank System. Accounts are numbered 1 … n; balance[i − 1] is the starting balance of account i. Implement Bank:
transfer(account1, account2, money)— movemoneyfromaccount1toaccount2.deposit(account, money)— addmoney.withdraw(account, money)— removemoney.
Each returns true if the operation succeeded. An operation fails (and changes nothing) if an account number is invalid or the source account has less than money.
Example
["Bank","withdraw","transfer","deposit","transfer","withdraw"]
[[[10,100,20,50,30]],[3,10],[5,1,20],[5,20],[3,4,15],[10,50]]
-> [null,true,true,true,false,false]
Then make it concurrent. Many threads call the bank at the same time. No update may be lost, a balance may never go negative, and transfers must not deadlock.
Constraints: 1 ≤ n ≤ 10^5; 0 ≤ balance[i], money ≤ 10^12; at most 10^4 calls.
Code runner format: two lines, LeetCode's format: the list of operations (starting with "Bank"), then the list of their argument lists. Implement the class Bank with transfer, deposit and withdraw; the harness prints the list of return values (null for methods that return nothing). (The runner checks the single-threaded behaviour.)