class solution {
public ListNode deleteNode (ListNode head,int val) {
if(head.val==val){
return head.next;
}
Listnode pre=head;
while((pre.next!=null&&pre.next.val!=null)){
pre=pre.next;
}
if(pre.next!=null){
pre.next=pre.next.next;
}
return head;
}
}

被折叠的 条评论
为什么被折叠?



