Skip to content

Linked Lists ​

AI Generated

No random access — you only ever hold next, so these problems are pure pointer bookkeeping rather than algorithmic cleverness.

  • Dummy head — a fake node in front of the real head deletes every "but what if it's the first node" branch.
  • Fast and slow pointers — the middle, the n-th node from the end, and cycle detection all fall out of two pointers moving at different rates or held a fixed gap apart. See Floyd's Rabbit and Turtle Algorithm.
  • Reverse in place — carry prev, curr, next. Reversal is the building block for reorder and palindrome checks.
  • Compose — most of the hard ones are just find middle → split → reverse → merge, done carefully.

Draw the pointers before writing, and re-trace the links after. The bugs are almost always a dropped node or a next pointing at itself.