// Remove Nth Node From End of List Given the head of a linked list, remove the nth node from the end of the list and return its head.
class Solution {
public ListNode removeNthFromEnd(ListNode head, int n) {
ListNode start=new ListNode();
ListNode fast=head;
ListNode slow=head;
for(int i=0;i<n;i++)
{
fast=fast.next;
}
->> while(fast.next!=null)
{
fast=fast.next;
slow=slow.next;
}
slow.next=slow.next.next;
return head;
}
}
** default case is working properly, Test cases is showing error is:[1]
java.lang.NullPointerException: Cannot read field "next" because "<local4>" is null
at line 27, Solution.removeNthFromEnd
at line 54, __DriverSolution__.__helper__
at line 87, __Driver__.main
Error is showing in the "->>"
**