How can this code not work for (206) Reverse Linked List ?

  • -1
    class Solution(object):
    def reverseList(self, head):
        if head is None or is None:
        pre = head
        head =
        while head is not None:
            temp =
   = pre
            pre = head
            head = temp
        return pre

    how could this take too much time ?please help me ,i cannot finger out any way ....

Log in to reply

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