1class Solution {2public:3ListNode *swapPairs(ListNode *head) {4// if head is NULL OR just having a single node, then no need to change5// anything6if (head == NULL || head->next == NULL) {7return head;8}910ListNode *temp; // temporary pointer to store head -> next11temp = head->next; // give temp what he want1213head->next = swapPairs(head->next->next); // changing links14temp->next = head; // put temp -> next to head1516return temp; // now after changing links, temp act as our head17}18};