← Pointer Walk

Pattern Recognition Drill

#10 — Delete node at position k

Easy Linked Lists

The Problem

Delete the node at position k (0-indexed) in a linked list.

What approach would you use?

Think about it before scrolling down.

Key Signals

Pointer Walk

Walk to node k-1, set prev.next = prev.next.next. O(k) time.

Common Trap

Forgetting to handle deletion of the head node (k=0) or going past the end.

← #9 #11 →