2021年3月19日星期五

How are these two different?

def reverseList(self, head):            prev, curr = None, head      while curr:          curr.next, prev, curr = prev, curr, curr.next      return prev  

I don't get the difference between this one above and

def reverseList(self, head):            prev, curr = None, head      while curr:          curr.next = prev          prev = curr          curr = curr.next      return prev  

Why do they have different results? I thought the way of first one and second ones' declaration are same.

https://stackoverflow.com/questions/66717651/how-are-these-two-different March 20, 2021 at 10:16AM

没有评论:

发表评论