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
November 29, 20260
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
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- 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 ProblemsSample 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...