- revise the val of the give node
- delete next node
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
class Solution {
// time complexity O(1) || space complexity O(1)
public void deleteNode(ListNode node) {
// copy the val of next node
node.val = node.next.val;
// delete next node
node.next = node.next.next;
}
}