In-place Reversal Linked List

Pasted image 20221226195331.png

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