```
public class Solution {
public ListNode removeNthFromEnd(ListNode head, int n) {
int i = 0;
ListNode start = new ListNode(1);
start.next=head;
ListNode list = start;
int len = length(list);
int t = len-n-1;
while(list!=null){
if(list.next==null) break;
if(i==t){
list.next=list.next.next;
}
else{
list=list.next;
i++;
}
}
return head;
}
private int length(ListNode node){
int len=0;
while(node!=null){
node=node.next;
len++;
}
return len;
}
```

}

Test Case: {1}, 1 expected {} output {1}