Problem · Hash Table
Account Balance Manager Part 1 - Calculate Totals
Learn this problemProblem statement
Practice sequence
- Part 1: Calculate Totals (you are here)
- Part 2: Reject Overdrafts
- Part 3: Platform Coverage
What the interview report shared
The coding round centered on Account Balance / Bank Transaction and contained three questions.
Practice contract
For this exercise, assume transactions arrive in order as account_id,amount strings. A positive amount is a deposit and a negative amount is a withdrawal.
Process every transaction and calculate each account's final balance. Return only accounts with a strictly positive final balance. Format each result as account_id:balance and sort the results lexicographically by account identifier.
Function
getAccountBalances(transactions: String[]) → String[]Examples
Example 1
transactions = ["account_A,100", "account_B,50", "account_A,-30", "account_C,200", "account_B,-50"]return = ["account_A:70", "account_C:200"]account_A: 100 - 30 = 70 (positive, kept). account_B: 50 - 50 = 0 (zero, removed). account_C: 200 (positive, kept). Output sorted by account_id.
Example 2
transactions = []return = []An empty transaction list yields no accounts.
Constraints
- Each transaction is
"account_id,amount";amountis an integer (positive deposit, negative withdrawal). - Process transactions in the given order, summing per account.
- Return only accounts with a final balance strictly greater than 0.
- Output entries are
"account_id:balance"sorted alphabetically by account_id.
More Stripe problems
- Group Linked Merchant RecordsPHONE SCREEN · Seen Jul 2026
- Invoice / Payment ReconciliationPHONE SCREEN · Seen Jul 2026
- Incident MonitorOA · Seen Jul 2026
- Merchant Fraud Risk ScoringOA · Seen Jul 2026
- WebSocket Load Balancer — Basic Load Balancing (Part 1)OA · Seen Jul 2026
- Rule-Driven Transaction Fraud DetectionOA · PHONE SCREEN · Seen Jul 2026
- Deployment Window SchedulerOA · Seen Jul 2026
- Directly Linked UsersOA · Seen Jun 2026