0ms solution in C language


  • -8
    B
    struct ListNode* swapPairs(struct ListNode* head) {
        struct ListNode* p = head;
        
        while (p != NULL && p->next != NULL) {
            p->val = p->val ^ p->next->val;
            p->next->val = p->val ^ p->next->val;
            p->val = p->val ^ p->next->val;
            p = p->next->next;
         }
        
        return head;
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.