Very easy python solution


  • 0
    P
    class Solution(object):
        def reverseList(Self, head):
            if head==None or head.next==None:
                return head
            prev=head
            cur=prev.next
            nex=cur.next
            while nex!=None:
                cur.next=prev
                prev=cur
                cur=nex
                nex=nex.next
            cur.next=prev
            head.next=None
            return cur

Log in to reply
 

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