Given a linked list, swap every two adjacent nodes and return its head.
For example, given
1->2->3->4, you should return the list as
This is a simple pointer manipulation problem. We can use the following list pointers:
a: the first of two nodes to be swapped at each iteration.
b: the second of two nodes to be swapped at each iteration
p: the node before
a at each iteration
tail: the remaining nodes of the list, to be swapped in the future iteration