Simple Python Solution


  • 0
    Y
    def removeNthFromEnd(self, head, n):
            
            dummy = ListNode(0) 
            dummy.next = head
            walker = dummy
            runner = dummy
            
            for i in range(n):
                runner = runner.next
                
            while(runner.next != None):
                walker = walker.next
                runner = runner.next
                
            walker.next = walker.next.next
            return dummy.next

Log in to reply
 

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