You are given the head of a linked list, write a program to swap each pair of adjacent nodes.

Problem Note

  • Linked List can be of even or odd size.
  • You shouldn't modify the values of nodes, rather swap the nodes itself

Example 1

Input: 10->20->30->40
Output: 20->10->40->30

Example 2

Input: 80->20->5->9->2
Output: 20->80->9->5->2

Example 3

Input: 1->2
Output: 2->1