Given a singly linked list, swap every two adjacent nodes (by relinking, not by swapping values) and return the list. If the list has an odd number of nodes, the last node stays in place. The list is given as an array; return the resulting array.
Input: An array of node values.
Output: Array — the list after pairwise swaps.
Input: [1,2,3,4,5]
Output: [2,1,4,3,5]
Explanation: Pairs swapped; last node unchanged.Input: [1,2,3,4]
Output: [2,1,4,3]
Explanation: Two pairs swapped.Input: [1]
Output: [1]
Explanation: Single node.0<=n<=10^40<=value<=10^9