Reconcile a bank statement with the ledger

A free medium coding practice problem from data. Solve it in JavaScript, TypeScript or Python and check your solution against fresh hidden tests — edge cases and random inputs — as often as you like.

Difficulty
Medium
Type
Function
Topic
Data
Languages
JavaScript, TypeScript or Python

Problem

Month-end reconciliation. bank and ledger are lists of [ref, amountInCents]. Bank exports are messy, so compare references after trimming surrounding spaces and lower-casing them (normalised references are unique within each list). Return an object with three keys, each list sorted by normalised reference (by character code): missingInLedger — references only in the bank statement; missingInBank — references only in the ledger; mismatched — [ref, bankAmount, ledgerAmount] for references in both whose amounts differ. All references in the output are normalised.

Function signature

// JavaScript
function reconcile(bank, ledger)

// TypeScript
function reconcile(bank: any, ledger: any): any

// Python
def reconcile(bank, ledger):

Examples

  1. reconcile([["TX100",5000],[" tx101 ",1200],["TX103",700]], [["tx100",5000],["tx101",1250],["tx102",300]]) → {"missingInLedger":["tx103"],"missingInBank":["tx102"],"mismatched":[["tx101",1200,1250]]}
  2. reconcile([["A1",1]], [["a1",1]]) → {"missingInLedger":[],"missingInBank":[],"mismatched":[]}

How checking works

Run your code against the examples above, then submit a check: it runs on the server against hidden tests built fresh each time, including edge cases and random inputs. Practice is untimed and never affects a verified score; when you are ready, take a graded coding challenge to earn a badge.

More practice problems

Next steps