Four-Level Banking System with Scheduled Payments
Updated
Problem statement
Process strictly increasing timestamped string queries. Before each query, execute due scheduled payments by due time then creation order.
CREATE_ACCOUNT,t,id,DEPOSIT,t,id,amount, andTRANSFER,t,source,target,amount.TOP_SPENDERS,t,nranks active accounts by outgoing total descending then ID ascending, formattedid(total).SCHEDULE_PAYMENT,t,id,amount,delayreturns a global payment ID; a due payment debits and counts as outgoing only when funds suffice.CANCEL_PAYMENT,t,id,paymentcancels an owned pending payment.MERGE_ACCOUNTS,t,first,secondabsorbs second into first, carrying balance, outgoing total, pending payments, and history.GET_BALANCE,t,id,timeAtreturns the latest balance at or before timeAt, or empty when unavailable.
Return one serialized string per query; invalid numeric operations return empty, and booleans use lowercase.
Function
processBankingQueries(queries: String[][]) → String[]Examples
Example 1
queries = [["CREATE_ACCOUNT","1","a"],["DEPOSIT","2","a","100"],["SCHEDULE_PAYMENT","3","a","30","5"],["GET_BALANCE","4","a","2"],["DEPOSIT","8","a","1"]]return = ["true","100","payment1","100","71"]The payment executes at timestamp 8 before the deposit.
Example 2
queries = [["CREATE_ACCOUNT","1","a"],["CREATE_ACCOUNT","2","b"],["DEPOSIT","3","a","50"],["TRANSFER","4","a","b","20"],["TOP_SPENDERS","5","2"]]return = ["true","true","50","30","a(20),b(0)"]The transfer contributes 20 outgoing for a.
Constraints
1 <= queries.length <= 500- Timestamps are unique and strictly increasing.
- Amounts and delays are positive.
More ZipRecruiter Online Assessment questions
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
- Count Case-Insensitive Key ChangesOA · Seen Sep 2024
Similar questions at other companies
- In-Memory File SystemAirbnb · OAAirbnb interview questions
- Power Cell BankOptiver · OAOptiver interview questions
- Task Management SystemCoinbase · OACoinbase interview questions
- Task Management SystemAnthropic · OAAnthropic interview questions
- Progressive Parcel Tracking OperationsKlaviyo · OAKlaviyo interview questions
- Versioned Recipe SystemThe Trade Desk · OA
- Recipe Management SystemRamp · OARamp interview questions
- Document and Layer OperationsFigma · OAFigma interview questions
- Worker Management with Promotions and Double-Paid TimeInstacart · ONSITE INTERVIEWInstacart interview questions
- Document Enrichment Stream AggregatorBloomberg LP · PHONE SCREENBloomberg LP interview questions