Read every scan. Write only the keepers.
transcript
Ten moves, or four copies? Two pointers clean this buffer with four copies. And no second buffer. Deleting and sliding needed ten moves here.
Read visits every slot, one at a time. Write marks the next free slot. Both start at 0. 52 is kept. It is copied onto itself.
Write moves to slot 1. Read finds minus 1. Skip it. Only read moves. Write waits at slot 1.
37 is kept. Copy it to slot 1. Two more no-reads. Write waits at slot 2. 18 goes straight to slot 2. 64 goes to slot 3.
Write moves only when read moves. So write never passes read. You never overwrite a scan you have not read.
The slots before write hold every kept scan. That is the kept prefix: 52, 37, 18, 64. Each scan is read once and copied at most once. A full buffer takes about two milliseconds. Deleting and sliding took about ten seconds.
Full breakdown in the lecture.