Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

leetcode 206 python

class Solution:
    def reverseList(self, head: ListNode) -> ListNode:
        if not head or not head.next:
            return head
        pre,tmp=None,None
        while(head):
            tmp=head.next
            head.next=pre
            pre=head
            head=tmp
        return pre
Source by www.codestudyblog.com #
 
PREVIOUS NEXT
Tagged: #leetcode #python
ADD COMMENT
Topic
Name
2+5 =