Preview:
class Solution
{
    public:
    Node* pairWiseSwap(struct Node* curr) 
    {
        // The task is to complete this method
        if(!curr || !curr->next)
            return curr;
        
        Node* nxtHead = pairWiseSwap(curr->next->next);
        Node* newHead = curr->next;
        curr->next->next = curr;
        curr->next = nxtHead;
        return newHead;
        
    }
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter