题解 | #删除链表的节点#
删除链表的节点
https://www.nowcoder.com/practice/f9f78ca89ad643c99701a7142bd59f5d
import java.util.*; public class Solution { public ListNode deleteNode (ListNode head, int val) { if(head.val==val) return head.next; if (head.next==null) return head; deleteNode(head.next,val); if (head!=null&&head.next.val==val) head.next = head.next.next; return head; } }
递归