The below code is for revsesing a linked list given the head of the list
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
if head is None or head.next is None:
return head
prev = None
curr = head
while curr:
curr.next, prev, curr = prev, curr, curr.next
return prev
How are we able to assign curr = curr.next(third assignment), when curr.next was assigned prev in the beginning?
Usually, a temp variable is used to store the value of curr.next, how are we bypassing that here?