Flag Unbalanced Journal Entries in a General Ledger Extract

Last updated: November 29, 2026

Quick Overview

Given general ledger lines as (entry_id, account, side, amount) where side is D or C, return every journal entry whose debits do not equal its credits, with the size of the imbalance.

EY
Coding & Algorithms
Software Engineer
EY
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

0

0 solved


Given general ledger lines as (entry_id, account, side, amount) where side is D or C, return every journal entry whose debits do not equal its credits, with the size of the imbalance.

Ledger integrity checks are the first step before EY Helix style audit analytics can run on a client's general ledger extract. In an entry-level GDS assessment this checks clean grouping logic, exact money arithmetic and sensible validation of messy input.

What the Interviewer Expects
  • Group lines by entry id in a single pass
  • Use exact decimal or integer cents arithmetic, never binary floats
  • Report the signed imbalance, not just a boolean
  • Reject or surface invalid sides and negative amounts instead of silently ignoring them
  • Return deterministic, sorted output
Key Topics to Cover
hash map grouping
decimal arithmetic
double-entry bookkeeping
input validation
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 handle a 200 million line extract that does not fit in memory?
  • What if amounts arrive in multiple currencies with a functional-currency column?
  • How would you also flag entries posted to a single account only?
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

Input is a list of ledger lines. An entry balances when the sum of its debit amounts equals the sum of its credit amounts. Output the entries that do not balance, each with debits - credits, sorted ...

High-Level Design

Keep one running net per entry id: add debits, subtract credits. After the pass, any non-zero net is an unbalanced entry. This is one dictionary and O(n) work, which is exactly what you want on a larg...


Submit Your Answer
Markdown supported

Related Questions