Skip to content

237_DeleteNodeinaLinkedList

a920604a edited this page Apr 14, 2023 · 1 revision

title: 237. Delete Node in a Linked List tags:
- Linked List categories: leetcode comments: false

solution

void deleteNode(struct ListNode* node) {
    node->val = node->next->val;
    node->next = node->next->next;
    
}

analysis

  • time complexity O(1)
  • space complexity O(1)
Clone this wiki locally