leetcode-剑指18-OK

language: C

address

// 憨憨题,不解释
/**
 * 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;
}
原文地址:https://www.cnblogs.com/gallien/p/14323576.html