FastPrepBank Accounts with Transfers and a Richest Lookup
Problems/Bank Accounts with Transfers and a Richest Lookup

Bank Accounts with Transfers and a Richest Lookup

Rippling logoRippling● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Our version replays a list of operations on a small bank: open an account, deposit, withdraw, transfer between two accounts, and look up the richest account. Every rule is our choice. Each operation returns one number, and -1 means it failed and changed nothing. A new account starts at 0 and opening a used id fails. A deposit or withdrawal returns the new balance, and a deposit never opens an account. A withdrawal or transfer larger than the balance fails, while one equal to it goes through. A transfer to the same account, or with an unopened account on either side, fails, and a successful one returns the sender's new balance. Richest gives the highest balance, the smaller id on a tie, counts empty accounts, and returns -1 when no account is open. The operation names, the limits (balances may pass the 32-bit range) and the examples are ours too.

A review from March 2022 places this task in the first coding round.

The review asks for an account class for a bank that supports deposits and withdrawals, and says the class then grew harder one step at a time. It does not name the later steps, the method names, the return values or any limits.

Our version is about 40% the same as the reported question.

Build a small bank. Each account has a whole-number id and a balance. Process the operations in order and return one number for each operation. A result of -1 means the operation failed and changed nothing.

  • "open" with args[i] = [id]: open a new account with balance 0 and return 0. If an account with this id is already open, return -1.
  • "deposit" with [id, amount]: add amount to the account and return its new balance. Return -1 if the account is not open. A deposit never opens an account.
  • "withdraw" with [id, amount]: take amount out of the account and return its new balance. Return -1 if the account is not open or its balance is less than amount. Taking out the whole balance is allowed.
  • "transfer" with [fromId, toId, amount]: move amount from account fromId to account toId and return the new balance of fromId. Return -1 if fromId and toId are the same, if either account is not open, or if the balance of fromId is less than amount.
  • "richest" with []: return the id of the open account with the highest balance. If several accounts tie, return the smallest id. Accounts with balance 0 count too. Return -1 if no account is open.

Balances can grow larger than a 32-bit integer can hold.

Function

runBank(operations: String[], args: int[][]) → long[]

Examples

Example 1

operations = ["open","open","deposit","deposit","richest","withdraw","richest","transfer","richest"]args = [[7],[3],[7,500],[3,300],[],[7,200],[],[7,3,300],[]]return = [0,0,500,300,7,300,3,0,3]

Accounts 7 and 3 open with 0. After the deposits, 7 has 500 and 3 has 300, so the richest is 7. Withdrawing 200 leaves 7 with 300: now both hold 300, and the smaller id, 3, wins. Account 7 then sends all of its 300 to account 3. Sending exactly the whole balance is allowed, and the transfer returns the sender's new balance, 0. Account 3 now holds 600 and is the richest.

Example 2

operations = ["richest","open","open","deposit","withdraw","deposit","withdraw","transfer","transfer","richest"]args = [[],[5],[5],[9,100],[5,1],[5,40],[5,40],[5,5,10],[5,8,10],[]]return = [-1,0,-1,-1,-1,40,0,-1,-1,5]

No account exists yet, so richest returns -1. Opening 5 works, but opening 5 again fails. Account 9 was never opened, so the deposit fails and does not create it. Account 5 has 0, so withdrawing 1 fails. After a deposit of 40, withdrawing exactly 40 works and leaves 0. A transfer from 5 to itself fails, and so does a transfer to account 8, which does not exist. Account 5 still counts for richest even with a balance of 0.

Example 3

operations = ["open","open","deposit","deposit","deposit","transfer","richest","transfer","richest"]args = [[1],[2],[1,1000000000],[1,1000000000],[1,1000000000],[1,2,1000000000],[],[1,2,1000000000],[]]return = [0,0,1000000000,2000000000,3000000000,2000000000,1,1000000000,2]

Three deposits of 1,000,000,000 give account 1 a balance of 3,000,000,000, which is too big for a 32-bit integer. After one transfer, account 1 has 2,000,000,000 and account 2 has 1,000,000,000, so 1 is the richest. After the second transfer, account 1 has 1,000,000,000 and account 2 has 2,000,000,000, so 2 is the richest.

Constraints

  • 1 <= operations.length <= 1000 and args.length == operations.length
  • Each operations[i] is "open", "deposit", "withdraw", "transfer" or "richest".
  • args[i] has 1 number for "open", 2 for "deposit" and "withdraw", 3 for "transfer", and none for "richest".
  • Every id and every amount is between 1 and 10^9.

More Rippling Phone Screen questions

  • Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dependency-Aware Task SchedulerPHONE SCREEN · Seen Nov 2026
  • Delivery Cost Tracker with Effective-Dated RatesPHONE SCREEN · Seen Nov 2026
  • Camel CardsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best and Worst Camel Card CompletionsPHONE SCREEN · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • In-Memory Priority Task SchedulerPHONE SCREEN · Seen Oct 2026
  • Limit an Organization Tree's HeightPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Median Across N Sorted ArraysPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • ID Allocator with Assign and ReleaseSnap Inc. · PHONE SCREENSnap Inc. interview questions
  • Key-Value Store on a Block DeviceLambda · PHONE SCREEN
  • 15-Minute Chat Session TrackerOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Capacity-Limited Timed CacheNetflix · PHONE SCREENNetflix interview questions
  • Design Authentication ManagerApple · PHONE SCREENApple interview questions
  • Tiered Expiring Item StoreHudson River Trading · PHONE SCREEN · ONSITE INTERVIEWHudson River Trading interview questions
  • Tiered Expiring Item StoreAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Multi-Level Inventory Storage SystemOptiver · OA · PHONE SCREENOptiver interview questions
  • Limit Order Book Matching EngineCitadel · PHONE SCREENCitadel interview questions
  • Document Enrichment Stream AggregatorBloomberg LP · PHONE SCREENBloomberg LP interview questions

Interview reports that mention this question

  • Rippling No-Level Older Reports: 31 Experiences (Part 6 of 6)

Rippling interview experiences

  • Rippling No-Level Onsite Loops: 24 Experiences (Part 5 of 6)
  • Rippling No-Level Screens and Loops: 18 Experiences (Part 4 of 6)
  • Rippling No-Level Coding Screens: 37 Experiences (Part 3 of 6)
  • Rippling No-Level Design, Screens: 30 Experiences (Part 2 of 6)
  • Rippling SWE Interviews, No Level: 156 Experiences (Part 1 of 6)
All Rippling interview questionsSee Rippling hiring insights
Saved
class Solution {
    public long[] runBank(String[] operations, int[][] args) {
        // Write your code here.
    }
}
Checking account…