privatestaticclassSolution{ public ListNode deleteNode(ListNode head, int val){ if (head.val == val){ return head.next; } ListNode pre = head , current = head.next;
while (current != null){ if (current.val == val){ pre.next = current.next; return head; } pre = current; current = current.next; } return head; } }