@@ -0,0 +1,1486 @@
+%22%22%22%0ARemove Nth Node From End of List%0AGiven a linked list, remove the nth node from the end of list and return its head.%0AFor example,%0AGiven linked list: 1-%3E2-%3E3-%3E4-%3E5, and n = 2.%0AAfter removing the second node from the end, the linked list becomes 1-%3E2-%3E3-%3E5.%0ANote:%0AGiven n will always be valid.%0ATry to do this in one pass. %0A%22%22%22%0A%0Aclass ListNode(object):%0A     def __init__(self, x):%0A         self.val = x%0A         self.next = None%0A%0A#Two-pass solution%0Aclass Solution(object):%0A    def removeNthFromEnd(self, head, n):%0A        %22%22%22%0A        :type head: ListNode%0A        :type n: int%0A        :rtype: ListNode%0A        %22%22%22%0A        length,pos=1,head%0A        while pos.next!=None:%0A            pos=pos.next%0A            length+=1%0A        %0A        if n==length:%0A            head=head.next%0A            return head%0A        for i in range(length-n):%0A            if i==0:%0A                p1=head%0A            else:%0A                p1=p1.next%0A            p2=p1.next.next%0A        p1.next=p2%0A        return head%0A%0A%0A#One-pass solution%0Aclass Solution(object):%0A    def removeNthFromEnd(self, head, n):%0A        %22%22%22%0A        :type head: ListNode%0A        :type n: int%0A        :rtype: ListNode%0A        %22%22%22%0A        dic=%7B%7D%0A        length,pos=1,head%0A        while pos.next!=None:%0A            dic%5Blength%5D=pos%0A            length+=1%0A            pos=pos.next%0A        if length==n:%0A            head=head.next%0A            return head%0A        else:%0A            dic%5Blength-n%5D.next=dic%5Blength-n%5D.next.next%0A            return head%0A

Create RemoveNodeEndofList.py