leetcode 237: Delete Node in a Linked List
2015-09-14 16:26
603 查看
题目:
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 -> 4and you are given the third node with value
3, the linked list should become
1 -> 2 -> 4after calling your function.
编码:
/** * 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) { node.val = node.next.val; node.next = node.next.next; } }
相关文章推荐
- nodejs模块hashmap
- Express作者TJ告别Node.js奔向Go
- Node.js 4.0 中的 ES 6 特性介绍
- node.js在windows下的安装与配置(附sublime-text的配置)
- nodejs 捕获未处理异常
- children和childNodes
- nodejs创建服务器和利用express创建服务器
- nodejs+express的简单示例
- Nodejs课堂笔记-第六课 在DynamoDB中如何创建表
- MonoDevelop几个常用的快捷键
- Node.js开发入门—套接字(socket)编程
- Node与Express开发 坑1
- C# readnodefile()不能读取带有文件名为汉字的osg文件解决方法
- XML解析之DOM解析引入GDataXMLNode的方法
- [前端] nodejs之express框架和ejs模板引擎的入门
- 【Node.js基础篇】(十)使用net模块和Readline模块实现Socket通信
- Swap Nodes in Pairs
- YARN源码分析(四)-----Journalnode
- LeetCode 237----Delete Node in a Linked List
- 为什么我要用 Node.js? 案例逐一介绍