Created
January 8, 2021 05:00
-
-
Save ceth-x86/4e39891ea2054b1b7f3fafd449d6013b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
ListNode* swapPairs(ListNode* head) { | |
ListNode **pp = &head, *a, *b; | |
while ((a = *pp) && (b = a->next)) { | |
a->next = b->next; | |
b->next = a; | |
*pp = b; | |
pp = &(a->next); | |
} | |
return head; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment