TC: O(n)
SC: O(1)
def reverseList(head):
prev = forw = None
curr = head
while curr:
forw = curr.next
curr.next = prev
prev = curr
curr = forw
return prev
def reverseList(head):
end = None
while head:
prev, head.next, head = head, prev, head.next
return prev