Skip to content

Commit e593980

Browse files
Merge pull request #102 from AkashSingh19/master
Added CPP code of swap nodes in pairs
2 parents d1efe93 + 2686886 commit e593980

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

24.swap nodes in pairs.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public:
3+
ListNode* swapPairs(ListNode* head) {
4+
if(!head || !head->next) return head;
5+
ListNode* temp;
6+
temp = head->next;
7+
head->next = swapPairs(head->next->next);
8+
temp->next = head;
9+
10+
return temp;
11+
}
12+
};

0 commit comments

Comments
 (0)