Keep the slowest task
transcript
Tasks in a warehouse fit-out. Each task needs other tasks first. The code finishes a day too early. Why?
Three tasks take one, five and one day. Task two needs both of the first two. It must wait for the slower one: five days. So the finish day is six.
Both prerequisites must be done first. The slower one decides the start. The faster one does not matter.
The bug overwrites the start day each time. The last write wins, even when it is smaller.
The buggy code returns five. The right answer is six.
Test two prerequisites, the slower one taken first. Then test the slower one taken last. And test a single chain.
Compare with the start already stored. Keep the larger one. Then reduce the wait count.
A task waits for its slowest prerequisite. Never overwrite a start time. Test two prerequisites. Full breakdown in the lecture.