Reconcile two ledgers
transcript
A bank keeps a list. The finance team keeps another. They must agree.
Both lists are sorted by id. Same id, compare the amounts. Otherwise report the smaller id.
The bank has one, two, four, five, eight. The books have two, three, four, five. Id four has a different amount.
The books end first. Id eight is still waiting. Report whatever is left.
Id one is only in the bank. Id three is only in the books. Id four differs, and id eight is the tail.
Each id is looked at once. That is linear time. The lists are already sorted.
Differences are real problems. An id on one side is a lost payment. A different amount is a typing error or a fee.
In the interview, say which list is sorted. Name the three kinds of report. And say what the tails mean.
Three outcomes in the loop. A loop for each tail. Full breakdown in the lecture.