Leetcode-237 Delete Node in a Linked List
#237. Delete Node in a Linked List
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) {}
* };
*/
class Solution {
public:
void deleteNode(ListNode* node) {
node->val=node->next->val;
node->next=node->next->next;
}
};
Leetcode-237 Delete Node in a Linked List的更多相关文章
- [LeetCode] 237. Delete Node in a Linked List 解题思路
Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...
- LeetCode 237. Delete Node in a Linked List (在链表中删除一个点)
Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...
- [LeetCode] 237. Delete Node in a Linked List 删除链表的节点
Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...
- (easy)LeetCode 237.Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...
- leetcode 237 Delete Node in a Linked List python
题目: Write a function to delete a node (except the tail) in a singly linked list, given only access t ...
- 17.leetcode 237. Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...
- [Leetcode]237. Delete Node in a Linked List -David_Lin
Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...
- LeetCode 237. Delete Node in a Linked List 删除链表结点(只给定要删除的结点) C++/Java
Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...
- [LeetCode] 237. Delete Node in a Linked List_Easy tag: Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...
- LeetCode 237 Delete Node in a Linked List 解题报告
题目要求 Write a function to delete a node (except the tail) in a singly linked list, given only access ...
随机推荐
- Python环境下NIPIR(ICTCLAS2014)中文分词系统使用攻略
一.安装 官方链接:http://pynlpir.readthedocs.org/en/latest/installation.html 官方网页中介绍了几种安装方法,大家根据个人需要,自行参考!我采 ...
- hdu 3999 The order of a Tree (二叉搜索树)
/****************************************************************** 题目: The order of a Tree(hdu 3999 ...
- 【转】ASP.NET ViewState详解
(wyt今天学习了这篇文章,作为门外汉的我了解了很多页面控件数据加载的知识和viewstate的用法和原理.我想在日后的开发效率提升上会有很大的作用.) 转自http://www.cnblogs.co ...
- 查看lock
select a.session_id,a.oracle_username, a.os_user_name, b.owner "OBJECT OWNER", b.object_na ...
- vbox进行克隆时时启动eth0时问题
在进行虚拟机克隆时会出现mac地址冲突,在进行网卡启动时,会出现device eth0 does not seem to be present问题,解决方案如下: 问题描述: device eth0 ...
- [linux] 线程和wait命令,sleep命令
在linux脚本编程中使用多线程编程,其中wait命令可以实现shell的多线程同步控制. 1. 启动后台子任务 在执行命令后加&操作符,表示将命令放在子shell中异步执行.可以达到多线程效 ...
- 读取XML文件的节点内的内容
<?xml version="1.0" encoding="utf-8" ?> <data> <tag3>15</ta ...
- 第六次课:springMVC与spring的集成
spring在项目中起到了管理bean的作用,即可以通过配置,让系统自动创建所需的对象,通过一定的方式引用系统创建的对象,对象的创建和引用都是由spring自动完成的,用户不必参与,可以直接引用. 实 ...
- HashMap源码解析
本文转载摘录自http://www.importnew.com/20386.html Java为数据结构中的映射定义了一个接口java.util.Map,此接口主要有四个常用的实现类,分别是HashM ...
- php实现验证码
验证码在表单实现越来越多了,但是用js的写的验证码,总觉得不方便,所以学习了下php实现的验证码.好吧,其实是没有事情干,但是又不想浪费时间,所以学习了下php实现验证码.正所谓,技多不压身.而且 ...