linked_list

025.Reverse-Nodes-in-k-Grouparrow-up-right (H-) 061.Rotate-Listarrow-up-right (M) 082.Remove-Duplicates-from-Sorted-List-II (M+) 086.Partition-Listarrow-up-right (M) 142.Linked-List-Cycle-IIarrow-up-right (M+) 109.Convert-Sorted-List-to-Binary-Search-Treearrow-up-right (M) 092.Reverse-Linked-List-IIarrow-up-right (H-) 143.Reorder-Listarrow-up-right (H-) 369.Plus-One-Linked-Listarrow-up-right (M) 430.Flatten-a-Multilevel-Doubly-Linked-Listarrow-up-right (H-) 457.Circular-Array-Looparrow-up-right (H-) 708.Insert-into-a-Cyclic-Sorted-Listarrow-up-right (H-) 1474.Delete-N-Nodes-After-M-Nodes-of-a-Linked-Listarrow-up-right (M+) 1670.Design-Front-Middle-Back-Queuearrow-up-right (M+) 1756.Design-Most-Recently-Used-Queuearrow-up-right (H)

Dummy node trick

  • Dummy Node trick: Maintain a list dummy head and actual tail pointer

    • Used across all linked list modification operations

LinkedListNode dummy = new LinkedListNode( 0 );
LinkedListNode tail = dummy;

// append one more element to the tail
tail.next = appendedNode;
// move tail pointer forward
tail = appendedNode;

return dummy.next; // pointing to the actual list head

Common tasks

  • Find median

  • Reverse list

  • Merge sorted list

Last updated