← ALL NOTES
Linked List

24. Swap Nodes in Pairs

Swapping a pair touches three nodes, not two: the node before the pair (prev) plus the two being swapped. Miss prev and you can't reattach the pair to the rest of the list. And since the rules forbid…

Loading…