剑指 Offer 18. 删除链表的节点

没什么难度。

class Solution {
    public ListNode deleteNode(ListNode head, int val) {
        ListNode dump = new ListNode(-1);
        dump.next = head;
        ListNode pre = dump;
        while (head != null){
            if(head.val == val){
                pre.next = head.next;
                return dump.next;
            }else{
                head = head.next;
                pre = pre.next;
            }
        }
        return dump.next;
    }
}

我的前方是万里征途,星辰大海!!
原文地址:https://www.cnblogs.com/taoyuxin/p/13468367.html