Stupid question took me over 2 hrs(copied from gfg)


#1

ListNode* Solution::swapPairs(ListNode* A){
ListNode *head=A,*prev,*curr;
if (head == NULL || head->next == NULL) return head;
prev=head;
curr=head->next->next;
head=head->next;
head->next=prev;

while(curr && curr->next)
{
    prev->next=curr->next;
    prev=curr;
    ListNode *next=curr->next->next;
    curr->next->next= curr;
    curr=next;
}
prev->next=curr;
return head;

}


#2

i feel you brdr 2 ghante baad gfg ne hee saath dia