237.Delete Node in a Linked List

Solution 1: accepted 3ms

1
2
3
4
5
6
public void deleteNode(ListNode node) {
if (node != null && node.next != null) { // not necessary in the question's scope
node.val = node.next.val;
node.next = node.next.next;
}
}