FastPrepBank Accounts with Balance History
Problems/Bank Accounts with Balance History

Bank Accounts with Balance History

Meta logoMeta● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported as the online test for Meta's AI Native Engineer role: a bank system built in several parts, where the last part works like a store that remembers every value over time so an earlier one can be looked up.

The report gives no operations, rules, examples or limits, so we chose the smallest version ourselves. You get all requests as one list of operations, at most 1000, each with its own timestamp: opening an account, deposits and transfers for the earlier parts, and asking for an account's balance at an earlier time for the last part. Opening an account returns 1, or 0 if it already exists. A deposit returns the new balance. A transfer returns the sender's new balance and cannot go to the same account. A deposit or transfer that cannot be done returns -1 and changes nothing. A balance asked for a given time counts every change made at or before that time, and a time before the account was opened gives -1.

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

Build a small bank that also remembers its past. You are given a list of operations in the order they happen. Each operation is a string array whose first two fields are the operation's name and its timestamp t.

  • ["CREATE", t, account] opens a new account with balance 0 and returns 1. If the account already exists, nothing changes and it returns 0.
  • ["DEPOSIT", t, account, amount] adds amount to the account and returns its new balance. It returns -1 if the account does not exist.
  • ["TRANSFER", t, from, to, amount] moves amount from account from to a different account to and returns the new balance of from. It returns -1 if either account does not exist, if from and to are the same account, or if from holds less than amount.
  • ["BALANCE_AT", t, account, time] returns the balance that account had at time time, that is, after every operation with a timestamp up to and including time. It returns -1 if the account did not exist at that time. This operation changes nothing.

A rejected operation changes no balance. Return an array with one result for each operation, in the same order.

Function

processBankOperations(operations: String[][]) → long[]

Examples

Example 1

operations = [["CREATE","1","alice"],["CREATE","2","bob"],["DEPOSIT","3","alice","500"],["TRANSFER","5","alice","bob","200"],["BALANCE_AT","6","alice","4"],["BALANCE_AT","7","bob","6"],["BALANCE_AT","8","bob","1"]]return = [1,1,500,300,500,200,-1]
  • Both accounts are created (1, 1). The deposit gives alice a balance of 500, and the transfer at time 5 leaves her 300.
  • At time 4 the transfer had not happened yet, so alice had 500. At time 6, bob had the 200 he received.
  • At time 1, bob did not exist yet (he was created at time 2), so the answer is -1.

Example 2

operations = [["CREATE","10","acct1"],["CREATE","20","acct1"],["DEPOSIT","30","acct2","50"],["DEPOSIT","40","acct1","50"],["TRANSFER","50","acct1","acct1","10"],["CREATE","60","acct2"],["TRANSFER","70","acct1","acct2","80"],["TRANSFER","80","acct1","acct3","10"],["BALANCE_AT","90","acct1","85"],["BALANCE_AT","95","acct3","90"]]return = [1,0,-1,50,-1,1,-1,-1,50,-1]
  • Creating acct1 a second time returns 0, and a deposit into acct2 before it exists returns -1.
  • A transfer from acct1 to itself, a transfer of 80 when acct1 holds only 50, and a transfer to the unknown acct3 are all rejected with -1.
  • Rejected operations change nothing, so acct1 still had 50 at time 85. acct3 never existed, so its answer is -1.

Example 3

operations = [["CREATE","100","x"],["DEPOSIT","200","x","7"],["DEPOSIT","300","x","3"],["BALANCE_AT","400","x","200"],["BALANCE_AT","500","x","199"],["BALANCE_AT","600","x","100"],["BALANCE_AT","700","x","99"],["BALANCE_AT","800","x","800"]]return = [1,7,10,7,0,0,-1,10]
  • A change made exactly at the asked time counts: at time 200 the balance was 7, but at time 199 it was still 0.
  • The account exists from time 100 on, so time 99 gives -1. Asking at the query's own time, 800, gives the current balance 10.

Constraints

  • 1 <= operations.length <= 1000
  • Each operation has exactly the fields shown above, and its name is one of CREATE, DEPOSIT, TRANSFER and BALANCE_AT.
  • Timestamps are integers from 1 to 10^9, strictly increasing from one operation to the next.
  • In a BALANCE_AT operation, 1 <= time <= t.
  • Account names have 1 to 10 characters, each a lowercase letter or a digit.
  • Every amount is an integer from 1 to 10^9.
  • All numbers are written as decimal strings without leading zeros.

More Meta interview questions

  • In-Memory Database with Historical Field LookupOA · Seen Sep 2026
  • Cave AdvantureOA · Seen May 2024
  • Closest Land Mark 👏OA · Seen Feb 2024
  • Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell StockPHONE SCREEN · Seen Nov 2026
  • First Element Greater Than KPHONE SCREEN · Seen Nov 2026
  • Count Events in Rolling Minute WindowsPHONE SCREEN · Seen Oct 2026
  • Valid Word AbbreviationPHONE SCREEN · Seen Oct 2026
  • Shortest Path in a Binary MatrixPHONE SCREEN · Seen Sep 2026
  • Deterministic K-Means AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Process Banking OperationsVercel · OA
  • Parcel Attribute Store with TTLAirbnb · OAAirbnb interview questions
  • Banking System with Historical SnapshotsCoinbase · OACoinbase interview questions
  • Consistent-Hash Packet RouterAmazon · PHONE SCREEN
  • Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • Process On-Call Routing OperationsOpenAI · PHONE SCREENOpenAI interview questions
  • Stateful Paginated Fetch NLyft · PHONE SCREENLyft interview questions
  • Escape Room LeaderboardPinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
  • Role-Based Network Access ControlOkta · PHONE SCREENOkta interview questions
  • Future-Effective Employee SalaryRippling · ONSITE INTERVIEWRippling interview questions

Interview reports that mention this question

  • Meta AI Native Engineer OA and Onsite: 1 Experience

Meta interview experiences

  • Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
  • Meta Business Support Engineer Phone Screen: 1 Experience
  • Meta Software Engineer Onsite Questions: 3 Experiences
  • Meta AI-Native Coding Interview: 3 Experiences
  • Meta Production Engineer Intern Questions: 6 Experiences
All Meta interview questionsSee Meta hiring insights
Saved
class Solution {
    public long[] processBankOperations(String[][] operations) {
        // Write your code here.
    }
}
Checking account…