Four-Level Banking System with Scheduled Payments
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.