Persona Intern Software Engineer Interview Experience — Banking OA with Refunds and Balance History

Persona·Software Engineer·Nov 2026
Online AssessmentInternmedium

September 18: Applied through campus recruiting.
October 9: Received the OA.
October 10: Finished the OA, 560/600.

A four-level CodeSignal OOD question: implement a banking account system. It was similar to other CodeSignal OOD questions, especially levels 1 and 2, with merging later on, but levels 3 and 4 were a little harder.

Create / Deposit accounts

createAccount(timestamp, accountId): boolean
Returns true if the account is created successfully.
Returns false if an account with accountId already exists.

deposit(timestamp, accountId, amount): Optional
Returns Optional.empty() if the account does not exist.
Otherwise, adds amount to the account's balance and returns the new balance.

transfer(timestamp, sourceAccount, targetAccount, amount): Optional
Returns Optional.empty() if either sourceAccount or targetAccount does not exist.
Returns Optional.empty() if sourceAccount == targetAccount.
Returns Optional.empty() if sourceAccount's balance is less than amount.
Otherwise, moves amount from sourceAccount to targetAccount and returns sourceAccount's remaining balance.

Find top spenders

topSpenders(timestamp, n): List
Returns the top n accounts ranked by total outgoing amount, highest first.
Outgoing is the sum of amounts sent via transfer, plus amounts paid via pay from Level 3 onward. It is not the number of transactions.
Ties are broken by accountId in lexicographic order.
If n exceeds the number of accounts, return all accounts.
Each entry is formatted as accountId(totalOutgoing).

Process payments

pay(timestamp, accountId, amount): Optional
Returns Optional.empty() if the account does not exist.
Returns Optional.empty() if the account's balance is less than amount.
Otherwise, deducts amount from the account at timestamp and adds amount to its outgoing total.
Schedules a refund of floor(amount * 0.02) back to the account at timestamp + 24h.
On success, returns a payment ID: "payment" plus an ordinal, such as "payment1", "payment2".

getStatus(timestamp, accountId, paymentId): Optional
Returns Optional.empty() if the account does not exist.
Returns Optional.empty() if the payment does not exist.
Returns Optional.empty() if the payment does not belong to accountId.
Otherwise, returns the payment's status: "in progress" until its refund has been processed, then "payment completed".

Merge accounts & preserve balance history

mergeAccounts(timestamp, accountId1, accountId2): boolean
Merges accountId2 into accountId1.
Returns false if either account does not exist.
Returns false if accountId1 == accountId2.
On success:
accountId2's balance is added to accountId1.
accountId2's total outgoing amount is added to accountId1's.
Any pending refunds for accountId2 are reassigned to accountId1.
accountId2 is removed from the system.
Returns true.

getBalance(timestamp, accountId, timeAt): Optional
Returns accountId's balance as it was at time timeAt.
Works even if accountId has since been merged away, as long as timeAt falls between the account's creation and its merge, inclusive.
At timeAt == mergeTimestamp, a merged-away account returns its final balance, not empty.
Returns Optional.empty() if timeAt is before the account was created or after it was merged away.

My Solution

Level 1
HashMap<String, Account> accounts: accountId → Account.
Account fields: accountId, balance, createdAt.

Level 2
Add totalOutgoing to Account; increment it on every successful transfer.
topSpenders: Sort accounts by totalOutgoing descending, with ties broken by accountId, take the first n, and format as accountId(totalOutgoing).

Level 3
New Payment class with fields:
accountId,
amount,
timestamp,
processAt = timestamp + 24h,
status (String), defaulting to "in progress".

TreeMap<Integer, Payment> pending: processAt → Payment.
HashMap<String, Payment> payments: paymentId → Payment.

pay:
Validate the account and its balance.
Deduct amount from the balance and add it to totalOutgoing.
Create a Payment, put it in both pending and payments, and return its payment ID.

processPayments(timestamp), a private helper:
Processes every payment in pending with processAt ≤ timestamp.
Refunds floor(amount * 0.02) to the payment's account.
Sets that payment's status to "payment completed".
Called at the start of every public method, so refunds always land first.

getStatus: Run the validations, then return payment.status.

Level 4 (I did not finish debugging)
mergeAccounts:
Add accountId2's balance and totalOutgoing to accountId1.
Instead of deleting accountId2 from accounts, set a new field removedAt = timestamp on it.
Existing logic gets an extra check: an account counts as nonexistent if it has been removed as of the call's timestamp.
Account gets a new field, TreeMap<Integer, Integer> history: timestamp → balance.
The balance is recorded at the end of each function call, under that call's timestamp.
getBalance: Look up history.floorKey(timeAt) and return that balance.

Published

Curated and edited by PracHub

Practice the questions from this interview

Discussion

Sign in to join the discussion. The author is notified of every comment.

Loading comments…

Interview at a glance

Company
Persona
Role
Software Engineer
Level
Intern
Rounds
Online Assessment
Difficulty
medium
Interview date
Nov 2026
Questions from this interview
1 question

Related interview experiences

Explore more interview rounds, questions, and outcomes.

Browse interview experiences