public ListNode removeNthFromEnd(ListNode head, int n) {
        ListNode current = head;
        ListNode tail = head;
        for(int i=0;i<n;i++)
            tail = tail.next;
        if(tail == null)
            return head.next;
        while(tail.next!=null)
        {
            current = current.next;
            tail = tail.next;
        }
        current.next = current.next.next;
        return head;
    }