Python Solution


  • 0
    I
        def reverseList(self, head):
            """
            :type head: ListNode
            :rtype: ListNode
            """
            cursor = head
            prev = None
            while cursor:
                right = cursor.next
                cursor.next = prev
                
                prev = cursor
                cursor = right
            return prev
    

Log in to reply
 

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