2.3 Delete Middle Node
2015-10-27 03:48
507 查看
The question requires that: we are not given access to the head of linked list. We only have access to the node which is going to be deleted.
So the solution is simply copying next node to the node which is going to be deleted.
So the solution is simply copying next node to the node which is going to be deleted.
void deleteNode(ListNode* node) { ListNode* tmp = node->next; *node = *node->next; delete tmp; }
相关文章推荐
- 解析Java中的队列和用LinkedList集合模拟队列的方法
- JAVA LinkedList和ArrayList的使用及性能分析
- LinkedList学习示例模拟堆栈与队列数据结构
- ArrayList和LinkedList的主要区别
- Java数据结构-线性表之单链表LinkedList
- ARRAYLIST VECTOR LINKEDLIST 区别与用法(2014-10-14)
- Remove Duplicates from Sorted List II
- Reverse Linked List
- Reverse Linked List II
- Partition List
- android性能之List
- Remove Nth Node From End of List
- Remove Duplicates from Sorted List
- Merge Two Sorted Lists
- ArrayList Vector LinkedList 区别与用法
- 黑马程序员————List集合概述、Arrayist集合、Vector集合、LinkedList集合简述
- 单向链表LinkedList的使用
- [Leetcode题解]002 Add Two Numbers
- LinkedList与ArrayList的区别
- Activity回退研究