Hand the value forward
transcript
A bank must close many ledgers. A ledger waits for its feeders. How many days will it take? One pass over the feeds can tell you.
A ledger with no feeder closes on day one. Any other ledger closes one day after its latest feeder. The answer is the largest day.
Ledgers zero and one close on day one. Ledgers two and four close on day two. Ledger three closes on day three. Ledger five closes on day four.
A node waits for all its feeders. Each feeder hands its day forward. So its day is final when taken.
Ledger three has two feeders. Keep the larger of the two days. Never overwrite the value.
Try every path in a layered graph, and there are 531,441. One pass over the 99 feeds is enough.
Take nodes in order. Hand each value forward with max. The answer is the best value. Full breakdown in the lecture.