237. Delete Node in a Linked List
2016-03-18 20:49
525 查看
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
you are given the third node with value
Subscribe to see which companies asked this question
Show Tags
Show Similar Problems
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.
Subscribe to see which companies asked this question
Show Tags
Show Similar Problems
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ public class Solution { public void deleteNode(ListNode node) { ListNode l =node.next; node.val=l.val; l=l.next; node.next=l; } }
相关文章推荐
- 24. Swap Nodes in Pairs
- ext2文件系统源代码之inode.c
- nodejs: mkdirs 递归创建目录
- HDFS的运行原理,NameNode,DataNode,client介绍
- 修复 OS X 的系统盘出现 Invalid Node Structure 问题
- Node.js初体验
- nodejs_os-utils模块 探坑
- Ubuntu安装nodejs最新版4.4和npm
- dom4j中 selectSingleNode 或selectNodes获取不到节点的原因总结 (转)
- Ubuntu 14.04 安装node js
- 模拟namenode宕机:数据块损坏,该如何修复
- 237. Delete Node in a Linked List
- [nodejs] nodejs开发个人博客(七)后台登陆
- leetcode 237 --Delete Node in a Linked List 链表 删除节点
- ovirt 之node安装
- nodejs错误:ld: library not found for -lgcc_s.10.5 clang: error: linker command failed with exit code 1 (use -v to see invocation)
- pomelo的HelloWorld
- 安装pomelo
- 欢迎使用pomelo
- leetcode 19. Remove Nth Node From End of List