Match General Ledger Cash Entries to Bank Statement Lines

Last updated: November 29, 2026

Quick Overview

Given ledger cash entries and bank statement lines, each with an id, a posting day and an amount in cents, match each ledger entry to at most one bank line with the same amount within a date tolerance, preferring the closest date. Return the matched pairs plus the unmatched items on each side.

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

0

0

0 solved


Given ledger cash entries and bank statement lines, each with an id, a posting day and an amount in cents, match each ledger entry to at most one bank line with the same amount within a date tolerance, preferring the closest date. Return the matched pairs plus the unmatched items on each side.

Bank reconciliation is one of the first things an audit analytics tool automates, so a short exercise like this fits an online assessment for engineers building PwC audit and finance tooling. The grader looks for clean grouping by amount, a deterministic tie-break, and awareness that money must be handled as integers.

What the Interviewer Expects
  • Group bank lines by exact amount so each lookup is cheap
  • Enforce the date tolerance and pick the closest unused bank line
  • Break ties deterministically so the output is reproducible for an auditor
  • Use integer cents rather than floats
  • Report both unmatched ledger entries and unmatched bank lines
Key Topics to Cover
Hashing and grouping
Greedy matching
Deterministic tie-breaking
Money as integers
Reconciliation
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
  • The greedy choice can be globally suboptimal; how would you get a maximum matching?
  • How would you support one ledger entry matching several bank lines that sum to it?
  • What changes if amounts can differ by bank fees of a few cents?
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

Inputs are two lists of (id, day, amount_cents). A match needs equal amounts and |bank_day - ledger_day| <= tolerance. Each bank line can be used once. Output: matched (ledger_id, bank_id) pairs...

High-Level Design

Index bank lines by amount into a dict of lists sorted by day. Process ledger entries in date order and, for each, scan only the bank lines with the same amount, choosing the unused candidate with the...


Submit Your Answer
Markdown supported

Related Questions