LeetCode--Delete Node in a Linked List
来源:互联网 发布:什么是贵族气质知乎 编辑:程序博客网 时间:2024/06/06 02:03
题目:
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.
Supposed the linked list is 1 -> 2 -> 3 -> 4
and you are given the third node with value 3
, the linked list should become 1 -> 2 -> 4
after calling your function.
代码:
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */
void deleteNode(ListNode* node) { if(node == NULL) return; else node->val = node->next->val; node->next = node->next->next; }
0 0
- leetcode: Delete Node in a Linked List
- LeetCode Delete Node in a Linked List
- 【leetcode】Delete Node in a Linked List
- Leetcode: Delete Node in a Linked List
- [LeetCode]Delete Node in a Linked List
- 【leetcode】Delete Node in a Linked List
- Leetcode Delete Node in a Linked List
- LeetCode || Delete Node in a Linked List
- [LeetCode] Delete Node in a Linked List
- LeetCode-Delete Node in a Linked List
- 【leetCode】Delete Node In A Linked List
- [leetcode] Delete Node in a Linked List
- [LeetCode]Delete Node in a Linked List
- [leetcode]Delete Node in a Linked List
- Leetcode: Delete Node in a Linked List
- LeetCode Delete Node in a Linked List
- LeetCode-Delete Node in a Linked List
- leetcode | Delete Node in a Linked List
- ArcGIS开发权威指南 上架
- 5个数求最值
- 关于java.sql.SQLException: Incorrect string value的解决方法
- InstallScript的事件
- 【大渣】【DP+单调队列优化】布丁
- LeetCode--Delete Node in a Linked List
- Java synchronized详解
- 电缆快速检测系统硬件设计
- MySQL导出数据到txt
- "undefined reference to" 问题解决方法
- APR 池
- JDBC:LOB---BLOB、CLOB
- 利用JDBC连接服务器数据库
- 蛇形填数