public ListNode removeNthFromEnd(ListNode head, int n) {
        ListNode dummy = new ListNode(0);
        ListNode front = dummy, back = dummy;
        dummy.next = head;

        while(n-- > 0) front = front.next;
        while(front.next != null){
            front = front.next;
            back = back.next;
        }

        back.next = back.next.next;
        return dummy.next;
    }