What is the difference between these two code?


  • 0
    N

    What is the difference between these two code?

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

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.