We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cc2069a commit 5098a50Copy full SHA for 5098a50
LinkedList/ReverseLinkedList.py
@@ -12,6 +12,20 @@ def reverse_iterative(self):
12
13
self.head = prev
14
15
+def reverse_recursive(self):
16
+
17
+ def _reverse_recursive(cur, prev):
18
+ if not cur:
19
+ return prev
20
21
+ nxt = cur.next
22
+ cur.next = prev
23
+ prev = cur
24
+ cur = nxt
25
+ return _reverse_recursive(cur, prev)
26
27
+ self._reverse_recursive(cur=self.head, prev=None)
28
29
30
class Node:
31
def __init__(self, data):
0 commit comments