• + 2 comments

    Thanks for this. I used the same process you did, but I completely forgot to set the tail node to None so my function kept timing out due to the circular reference.

    Here's my Python implementation:

    def Reverse(head):
        if not head or not head.next: return head
        newHead = Reverse(head.next)
        head.next.next = head
        head.next = None
        return newHead