Python recursive solution for reverse a linked list .


  • 0
    S

    class Solution:

    def reverseList(self, head):
        if head is None or head.next is None:
            return head
        
        root=self.reverseList(head.next)
        
        head.next.next=head
        head.next=None
        
        return root

Log in to reply
 

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