Same code with different result

  • 0
    def reverseList(self, head):
        r = None
        while head:
           head,, r =, r, head

    Here is my result:

    Runtime Error Message: Line 17: AttributeError: 'NoneType' object has no attribute 'next'

    Last executed input: [1]

  • 0

    differnt code!Becaue in your code,, r=head. As a result should change the order.

Log in to reply

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