diff --git a/24.swap nodes in pairs.cpp b/24.swap nodes in pairs.cpp new file mode 100644 index 0000000..faa6034 --- /dev/null +++ b/24.swap nodes in pairs.cpp @@ -0,0 +1,12 @@ +class Solution { +public: + ListNode* swapPairs(ListNode* head) { + if(!head || !head->next) return head; + ListNode* temp; + temp = head->next; + head->next = swapPairs(head->next->next); + temp->next = head; + + return temp; + } +}; \ No newline at end of file