leetcode-Delete Node in a Linked List
2015-11-03 19:23
751 查看
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
with value
将删除节点的值用该节点的下一个节点值代替,同时将该节点的下一个节点的下一个节点连到该节点后面。
Supposed the linked list is
1 -> 2 -> 3 -> 4and you are given the third node
with value
3, the linked list should become
1 -> 2 -> 4after calling your function.
将删除节点的值用该节点的下一个节点值代替,同时将该节点的下一个节点的下一个节点连到该节点后面。
public class Solution { public void deleteNode(ListNode node) { ListNode p=node.next; node.val=p.val; node.next=p.next; } }
相关文章推荐
- nodejs
- ubuntu 开发环境配置及安装 nodejs
- ubuntu 开发环境配置及安装 nodejs
- node.js 中createConnection参数说明
- Node开发项目管理工具 Grunt 对比 Gulp
- Node.js入门
- node express
- LeetCode--Delete Node in a Linked List
- [美国VPS]Ramnode测试
- node.js创建并引用模块
- NodeJS 模块开发及发布详解分享
- 如何发布Node模块到NPM社区
- LeetCode Delete Node in a Linked List 链表
- LeetCode Count Complete Tree Nodes 二叉树
- 《leetCode》:Remove Nth Node From End of List
- 搭建Windows Node.js环境
- Node.js中处理异步编程(使用回调处理一次性事件,使用事件监听器处理重复性事件)
- 节点的nodeName与nodeValue
- 在eclipse中安装node.js环境
- zabbix监控磁盘inode使用百分比