Skip to content

Commit 1ca2d40

Browse files
author
Sahil
authored
Update ReverseLinkedList.cpp
Added Recursive implementation
1 parent b2c601a commit 1ca2d40

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Linked-Lists/ReverseLinkedList.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,15 @@ ListNode* Solution::reverseList(ListNode* A) {
2929

3030
return prev;
3131
}
32+
33+
// A recursive implementation for the same problem.
34+
//
35+
// ListNode* Solution::reverseList(ListNode* A) {
36+
// if(!A || !A->next)return A;
37+
38+
// ListNode* head = A->next;
39+
// ListNode* p = reverseList(A->next);
40+
// A->next->next = A;
41+
// A->next = NULL;
42+
// return p;
43+
// }

0 commit comments

Comments
 (0)