Swap Nodes in Pairs
mediumSwap every two adjacent nodes by rewiring pointers (not just swapping values)
Swap Nodes in Pairs
Key Insight
Rewire prev→second→first→rest for each pair; a dummy node handles the head swap
Step 1Setup with Dummy
Pairs: (1,2) and (3,4)
prev
D
1
2
3
4
null
Add dummy before [1,2,3,4]. prev starts at dummy.
1 / 5