@@ -0,0 +1,1298 @@
+package leetcode.remove_nth_node_from_end_of_list;%0A%0Aimport java.util.ArrayList;%0A%0Aimport common.ListNode;%0A%0Apublic class Solution %7B%0A%09public ListNode removeNthFromEnd(ListNode head, int n) %7B%0A%09%09if(head == null %7C%7C n == 0)%7B%0A%09%09%09return head;%0A%09%09%7D%0A%09%09if(n == 1 && head.next == null) return null;%0A%09%09int size = 0;%0A%09%09ListNode cur = head;%0A%09%09while(cur != null)%7B%0A%09%09%09cur = cur.next;%0A%09%09%09size += 1;%0A%09%09%7D%0A%09%09n = size - n;%0A%09%09if(n == 0)%7B%0A%09%09%09head = head.next;%0A%09%09%7Delse%7B%0A%09%09%09cur = head;%0A%09%09%09ListNode prev = null;%0A%09%09%09while(n %3E 0)%7B%0A%09%09%09%09prev = cur;%0A%09%09%09%09n--;%0A%09%09%09%09cur = cur.next;%0A%09%09%09%7D%0A%09%09%09prev.next = cur.next;%0A%09%09%7D%0A%09%09return head;%0A%09%7D%0A%0A//%09public static class ListNode %7B%0A//%09%09int val;%0A//%09%09ListNode next;%0A//%09%09ListNode(int x) %7B%0A//%09%09%09val = x;%0A//%09%09%09next = null;%0A//%09%09%7D%0A//%09%09public void dump()%7B%0A//%09%09%09ListNode cur = this;%0A//%09%09%09while(cur != null)%7B%0A//%09%09%09%09System.err.println(%22val = %22 + cur.val);%0A//%09%09%09%09cur = cur.next;%0A//%09%09%09%7D%0A//%09%09%09System.err.println(%22%22);%0A//%09%09%7D%0A//%09%7D%0A%09%0A%09public static void main(String%5B%5D args)%7B%0A%09%09final int N = 10;%0A//%09%09Solution sol = new Solution();%0A%09%09for(int i = 0; i %3C= N; i++)%7B%0A%09%09%09ArrayList%3CListNode%3E ary = new ArrayList%3CListNode%3E();%0A%09%09%09for(int j = 0; j %3C N; j++)%7B%0A%09%09%09%09ary.add(new ListNode(j));%0A%09%09%09%09if(j %3E 0) ary.get(j - 1).next = ary.get(j);%0A%09%09%09%7D%0A//%09%09%09ListNode head = sol.removeNthFromEnd(ary.get(0), i);%0A//%09%09%09head.dump();%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add java solution for 19. Remove Nth Node From End of List