20200728 链表 - 删除链表节点

https://mp.weixin.qq.com/s/Xo1m0q7ic7r2WV9wDO5H9Q

知识点:

 

 

public ListNode deleteNode(ListNode head,int val){
  if(head.val=val){
    return head.next;
  }

  ListNode pre=head,cur=head.next;
  while(cur!=null&&cur.val!=val){
    pre=cur;
    cur=cur.next;  
  }

  pre.next=cur.next;
  return head;
}
posted @ 2020-07-28 13:45  vivian_xiaoyun  阅读(116)  评论(0编辑  收藏  举报