Take a linked list and swap every two nodes that are next to each other (the 1st with the 2nd, the 3rd with the 4th, and so on). Return the new head.
You must not change the values inside the nodes. Only change the links between the nodes. If one node is left over at the end, it stays where it is.
How the judge passes the data
Examples
Example 1:
Input: head = [10,20,30,40,50]
Output: [20,10,40,30,50]
Explanation: 10 and 20 swap, 30 and 40 swap, and 50 is alone.
Example 2:
Input: head = [3,6]
Output: [6,3]
Explanation: One pair is swapped.
Example 3:
Input: head = []
Output: []
Explanation: There is nothing to swap.