Submission Result: Runtime Error

Last executed input: {1,2,3}, 1

```
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *removeNthFromEnd(ListNode *head, int n) {
if(head == NULL) return NULL;
ListNode *p1, *p2;
p1 = head->next;
p2 = head;
int i = 0;
while(p1 != NULL && p2 != NULL)
{
if(i++<n+1)
{
p2 = p2->next;
}
else
{
p1 = p1->next;
p2 = p2->next;
if (p2->next == NULL)
{
ListNode *temp = p1->next;
p1->next = temp->next;
delete temp;
break;
}
}
}
return head;
}
};
```