loading

Partition List — Step-by-Step Visualization

mediumLeetCode #86Linked ListTwo Pointers

Partition linked list around value x so all < x come before >= x, preserving relative order.

Algorithm Pattern

Two Dummy Lists

Key Idea

Build two separate lists and concatenate.

Step-by-Step Approach

  1. Two dummy heads: less and greater
  2. For each node: route to appropriate list
  3. Connect less.next = greater_dummy.next

Related Problems