educative.io

Educative

How does reversing the second half of the LinkedList bring the LinkedList back to its original form

Hello,
Can you please explain the technical details on how the original list is restored?
Thanks,
Kiran

When you reversed second half using
headSecondHalf = reverse(slow);

Now after the matching since you stored the headSecondHalf head in copyHeadSecondHalf
with reverse(copyHeadSecondHalf) it will reverse back.