struct ListNode* deleteDuplicates(struct ListNode* head) {
if(head == NULL || head->next == NULL)
{
return head;
}
struct ListNode* p=head;
while(p->next != NULL)
{
if(p->val == p->next->val)
{
p->next = p->next->next;
}
else
{
p=p->next;
}
}
return head;
}
struct ListNode* deleteDuplicates(struct ListNode* head) {
if(head == NULL || head->next == NULL)
{
return head;
}
struct ListNode* p=head->next;
while(p != NULL)
{
if(p->val == p->next->val)
{
p->next = p->next->next;
}
else
{
p=p->next;
}
}
return head;
}
为什么第2份报Line 16: Char 29: runtime error: member access within null pointer of type 'struct ListNode' [solution.c]循环判断体设置有什么问题