@@ -0,0 +1,777 @@
+# Definition for singly-linked list.%0Aclass ListNode:%0A    def __init__(self, x):%0A        self.val = x%0A        self.next = None%0A%0Aclass Solution:%0A    # @return a ListNode%0A    def removeNthFromEnd(self, head, n):%0A        if n %3C 0 or head == None:%0A            return head%0A%0A        d = %7B%7D%0A%0A        current =  head%0A        l = 0%0A        while current:%0A            d%5Bl%5D = current%0A            current = current.next%0A            l += 1%0A%0A        if n == 0:%0A            d%5Bl - 1%5D.next = None%0A            return head%0A        elif n %3E l:%0A            return head%0A        elif n == l:%0A            if l == 1:%0A                return None%0A            else:%0A                return d%5B1%5D%0A        elif n %3C l:%0A            idx = l - n%0A            d%5Bidx - 1%5D.next = d%5Bidx%5D.next%0A            return head%0A%0A%0A

Remove Nth Node From End of List 58ms should be more optimal