public static ListNode removeNthFromEnd(ListNode head, int n) {
        if(head == null) return null;

        ListNode first = head, second = head;

        for(int i = 0; i < n; i++) second = second.next;

        if(second == null) return first.next;

        while(second.next != null){
            first = first.next;
            second = second.next;
        }

        first.next = first.next.next;
        return head;
    }