Leetcode Problem 237. Delete Node in a Linked List

237. Delete Node in a Linked List

Leetcode Solutions

Delete Node in a Linked List by Copying Next Node's Data

  1. Store the next node (node.next) in a temporary variable called next_node.
  2. Copy the value of next_node to the current node (node.val = next_node.val).
  3. Set the current node's next pointer to point to next_node's next node (node.next = next_node.next).
  4. The original next node is now effectively removed from the list.
UML Thumbnail

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...