language: C
// 憨憨题,不解释
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* deleteNode(struct ListNode* head, int val){
if(head->val == val)
return head->next;
struct ListNode* p =head->next;
struct ListNode* pre =head;
while(p->val !=val){
pre = p;
p = p->next;
}
pre->next = p->next;
return head;
}