class Solution:
    def removeNthFromEnd(self , head: ListNode, n: int) -> ListNode:
        if not head: return None
        mark,mark.next,node=ListNode(0),head,self.find_node(head, n)
        curr=mark
        while curr:
            if curr.next==node:
                curr.next=curr.next.next
                break
            curr=curr.next
        return mark.next
    
    def find_node(self,head,n):
        left,right=head,head
        for _ in range(n):
            right=right.next
        while right:
            left=left.next
            right=right.next
        return left