Answers for "leetcode 206 python"

0

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
Posted by: Guest on September-29-2021

Python Answers by Framework

Browse Popular Code Answers by Language