ListNode *swapPairs(ListNode *head) {
if (head == nullptr || head->next == nullptr)
return head;
ListNode *it = head;
head = head->next;
it->next = head->next;
head->next = it;
while (it->next != nullptr && it->next->next != nullptr) {
ListNode *temp = it->next;
it->next = it->next->next;
temp->next = it->next->next;
it->next->next = temp;
it = it->next->next;
}
return head;
}