Delete Node in a Linked List

Solution Code
class Solution:
    def deleteNode(self, node):
        # Overwrite data of next node on current node.
        node.val = node.next.val
        # Make current node point to next of next node.
        node.next = node.next.next
Video GuideLeetcode Daily

Time Complexity

O(1)

Space Complexity

O(1)