Back to blog

Linked List Problems and Tricks

6 March 20262 min read

Dummy Node Trick

Use a dummy head so you don't need special cases for the first node when building a new list (e.g. merge two lists, remove elements).

Reversal

  • Iterative: Three pointers (prev, curr, next); reverse links one by one.
  • Recursive: Reverse rest, then link current to the new tail.

Cycle Detection

Floyd's algorithm: Slow and fast pointer; if they meet, there's a cycle. To find cycle start: reset slow to head, move both one step at a time until they meet.

Merging and Splitting

  • Merge two sorted lists: dummy node, compare and attach.
  • Merge K sorted lists: min-heap of size K.
  • Split: traverse with two pointers or count nodes first.

Other Classic Problems

  • Remove Nth node from end: two pointers, gap N.
  • Palindrome: find middle, reverse second half, compare.
  • Reorder list: find middle, reverse, merge two halves.

Summary

Dummy node, reversal, and fast-slow pointer cover most list problems. Practice on Preplume(/) to build speed.

Related posts

Common DSA Mistakes and How to Avoid Them

Typical mistakes in coding interviews: off-by-one errors, wrong complexity, and how to avoid them.

14 Mar 20262 min readRead more