The middle post, twice
transcript
Reorder posts from both ends. First, last, second, second to last. The middle post appears twice. It only happens when the count is odd.
Three posts: one, two, three. The first pair is one and three. Now both cursors sit on two. There is nothing left to pair it with.
The loop runs while left is at most right. It places two, and the check after the loop places it again. Run only while left is less than right. The samples with an even count never show it.
Loop while left is less than right. Then check whether the cursors are equal. If they are, place the middle once. That is one comparison and one line.
Test one post. The answer is that post. Test two posts, then three posts. An odd count is where the slip hides.
Odd counts leave a middle. Place it after the loop. Full breakdown in the lecture.