Apply Multi-Currency Journal Entries to a Double-Entry Ledger

Last updated: November 29, 2026

Quick Overview

Implement a ledger that applies journal entries, each a list of (account, currency, delta) legs, rejecting entries that are unbalanced per currency or that would overdraw an internal account, and applying accepted entries atomically and idempotently.

Bridge
Coding & Algorithms
Software Engineer
Bridge
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Implement a ledger that applies journal entries, each a list of (account, currency, delta) legs, rejecting entries that are unbalanced per currency or that would overdraw an internal account, and applying accepted entries atomically and idempotently.

Everything Bridge does, from an ACH deposit to a USDC payout, ends up as ledger movements across customer, fee and external accounts. This onsite exercise checks whether you understand double-entry invariants, atomicity and replay safety, which matter more than clever algorithms in money movement code.

What the Interviewer Expects
  • Enforce that legs sum to zero within each currency, not across currencies
  • Net multiple legs on the same account before checking balances
  • Validate everything first, then apply, so a rejected entry leaves no partial effect
  • Make replays of the same entry id a no-op
  • Distinguish external accounts that may go negative from customer accounts that may not
Key Topics to Cover
double-entry accounting
atomicity
idempotency
multi-currency
invariants
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you persist this in Postgres so concurrent entries cannot both pass the balance check?
  • How do you represent a stablecoin conversion where USD leaves and USDC arrives?
  • What would you add to support pending versus posted balances?
  • How would you reverse an entry that was applied by mistake?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Balances are integers in each currency's minor unit (cents for USD, 10^-6 for USDC). An entry needs at least two legs; for each currency the deltas must sum to zero. Accounts outside may_go_negative...

High-Level Design

Process entries in order. For each: group deltas by currency for the balance check, and net them by (account, currency) for the overdraft check, since an entry might debit and credit the same account....


Submit Your Answer
Markdown supported

Related Questions