dsa1 min read
Partition List — Two Dummy Head Chains
Partition a linked list around value x into less-than and greater-than-or-equal chains, then join them.
Read →
1575 articles
Partition a linked list around value x into less-than and greater-than-or-equal chains, then join them.
Sort a linked list in O(n log n) time and O(log n) space using top-down merge sort with fast/slow split.
Remove all nodes that have duplicate numbers from a sorted linked list using a dummy head and skip logic.
Deep copy a linked list with random pointers using either a hash map or the O(1) space interleave technique.
Flatten a multilevel doubly linked list by inserting child sub-lists inline using DFS or an explicit stack.