In-place Reversal Linked List

Iterative
def reverse(start: Node) -> Node:
curr = start
previous = None
while curr:
next = curr.next
curr.next = previous
previous = curr
curr = next
return previous
class Node:
__slots__ = ['next', 'value']
def __init__(self, value: int):
self.value = value
self.next = None
Recursive
class App:
def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:
if not head: return
nextHead = head
if head.next:
nextHead = self.reverseList(head.next)
head.next.next = head
head.next = None
return nextHead