CodePudding user response:
Delete the first while the above two sentences code, remove the first if the third sentence p=p - & gt; nextCodePudding user response:
Struct ListNode * delete (struct ListNode * head){
If (NULL==head) return the head;//empty table
If (NULL==head - & gt; Next) return the head;//only one element table
PFirst ListNode * and * pSecond;
PFirst=head; PSecond=head - & gt; Next;
While (pSecond) {
If (pFirst - & gt; Val==pSecond - & gt; Val) {
PFirst - & gt; Next=pSecond - & gt; Next;
Free (pSecond);
PSecond=pFirst - & gt; Next;
continue;
}
PFirst=pSecond;
PSecond=pSecond - & gt; Next;
}
return head;//no matter what the head pointer is not become
}
CodePudding user response:
In front of the code is not empty nodes ListNode list, if there is initialized once more just judgmentCodePudding user response: