public ListNode removeNthFromEnd_v3(ListNode head, int n) {
        if (head == null)
            return head;
        ListNode dummy = new ListNode(-1);
        dummy.next = head;
        // head = dummy;
        ListNode ptr = dummy;
        head = dummy;
        for (int i = 0; i < n; ++i) {
            if (head == null)
                return null;
            head = head.next;
        }
        while (head.next != null) {
            head = head.next;
            ptr = ptr.next;
        }
        ptr.next = ptr.next.next;
        return dummy.next;
    }