卿卿如梦

关注

力扣 Java 203. 移除链表元素

卿卿如梦

关注

阅读 68

2022-02-15

  • 全部代码 
public class Num203 {
    public ListNode removeElements(ListNode head, int val) {
        ListNode dummyHead = new ListNode(-1);
        dummyHead.next = head;
        ListNode prev = dummyHead;
        while (prev.next != null){
            if (prev.next.val == val){
                //找到待删除节点
                prev.next = prev.next.next;
            }else {
                prev = prev.next;
            }
        }
        return dummyHead.next;
    }
}

 

相关推荐

三维控件研究

203. 移除链表元素

三维控件研究 35 0 0

毅会

Leecode 203. 移除链表元素

毅会 69 0 0

IT影子

【LeetCode】203. 移除链表元素

IT影子 40 0 0

流沙雨帘

LeetCode 203. 移除链表元素

流沙雨帘 113 0 0

芝婵

【Leetcode】203. 移除链表元素

芝婵 10 0 0

程序猿不脱发2

【 LeetCode题解 】203. 移除链表元素

程序猿不脱发2 22 0 0

不会弹吉他的二郎腿

leetcode算法203.移除链表元素

不会弹吉他的二郎腿 79 0 0

生命中最美的是成长

【LeeCode】203. 移除链表元素 -- todo

生命中最美的是成长 163 0 0

慕容冲_a4b8

【链表Linked List】力扣-203 移除链表元素

慕容冲_a4b8 46 0 0

非凡兔

2022/1/18 链表 || 203. 移除链表元素

非凡兔 116 0 0

精彩评论(0)

0 0 举报