Stay after you unlink
transcript
A sorted chain holds repeated prices. You must unlink each repeat in place. Moving the cursor too early leaves repeats behind. Here is the rule that avoids it.
Three equal prices. The cursor is on the first. The next price is equal, so unlink it. The next price is equal again. Unlink that one as well. One price is left.
If the cursor moves after each unlink, it checks too little. It returns one, one. A repeat is left in the chain. Stay in place, and the result is one.
When the next price is equal, unlink it and stay. When it differs, move the cursor on. When there is no next node, stop.
This chain has eight nodes before the edit. After the edit it has three: four, seven and nine.
Unlink a repeat, and keep the cursor. Move only when the next price differs. Full breakdown in the lecture.