Delete Node in a Linked List LeetCode solution in Java

1
class Solution {
2
public void deleteNode(ListNode node) {
3

4
// 4 5 1 9 : Node = 5
5

6
node.val = node.next.val;
7

8
// Copy next node val to current node.
9
// 4 1 1 9
10
// ------------
11

12
// Point node.next = node.next.next
13
// 4 -----> 1 ----> 9
14

15
node.next = node.next.next;
16
// 4 1 9
17
}
18
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0