【4_237】Delete Node in a Linked List
Delete Node in a Linked List
Total Accepted: 48121 Total Submissions: 109297 Difficulty: Easy
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.
Subscribe to see which companies asked this question
不容易自己写对一道题,没有查找答案~
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
void deleteNode(struct ListNode* node) {
struct ListNode* p = node->next;
node->val = p->val;
if (p->next == NULL)
node->next = NULL;
else
node->next = p->next;
free(p);
}
【4_237】Delete Node in a Linked List的更多相关文章
- 237. Delete Node in a Linked List【easy】
		
237. Delete Node in a Linked List[easy] Write a function to delete a node (except the tail) in a sin ...
 - 【LeetCode】237 & 203 - Delete Node in a Linked List & Remove Linked List Elements
		
237 - Delete Node in a Linked List Write a function to delete a node (except the tail) in a singly l ...
 - LeetCode Javascript实现 283. Move Zeroes 349. Intersection of Two Arrays 237. Delete Node in a Linked List
		
283. Move Zeroes var moveZeroes = function(nums) { var num1=0,num2=1; while(num1!=num2){ nums.forEac ...
 - 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 singl ...
 - [CareerCup] 2.3 Delete Node in a Linked List 删除链表的节点
		
2.3 Implement an algorithm to delete a node in the middle of a singly linked list, given only access ...
 - 237. Delete Node in a Linked List(C++)
		
237. Delete Node in a Linked Lis t Write a function to delete a node (except the tail) in a singly l ...
 - [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
		
237. Delete Node in a Linked List Easy Write a function to delete a node (except the tail) in a sing ...
 - 【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 t ...
 
随机推荐
- nodejs将PDF文件转换成txt文本,并利用python处理转换后的文本文件
			
目前公司Web服务端的开发是用Nodejs,所以开发功能的话首先使用Nodejs,这也是为什么不直接用python转换的原因. 由于node对文本的处理(提取所需信息)的能力不强,类似于npm上的包: ...
 - python笔记一
			
好奇,想一探究竟.安装就出点小问题,win7,64位,一直卡在这里不动了? 只好取消.第二天安装仍是如此. 于是下载Windows6.1-KB2999226-x64.msu,安装,仍卡顿不动: 于是找 ...
 - 关于position:absolute的困惑
			
今天在学习<精通css>时碰到一个问题,第六章“对列表应用样式和创建导航条”中的“Suckerfish下拉菜单”中,为了创建导航条的下拉菜单,文中提到的方法是:先设置下拉菜单的positi ...
 - SQL笔记-第四章,数据的检索
			
一.select的简单用法 1.简单的数据检索 SELECT * FROM T_Employee; 2.检索出需要的列 SELECT FNumber,FName,FAge FROM T_Employe ...
 - jQuery MD5加密实现代码
			
$(md("你想要加密的字符串")); md5插件下载地址:http://xiazai.jb51.net/201003/yuanma/jquery_md5.rar 下面是我的简单例 ...
 - c# winform 打包部署 自定义界面 或设置开机启动
			
添加安装部署项目后,鼠标右键安装项目->视图->注册表, 要使软件在开机就运行,可以在HKEY_CURRENT_USER\Software\Microsoft\Windows\Curren ...
 - apache相关
			
http://hw1287789687.iteye.com/blog/2212292 http://enable-cors.org/server_apache.html http://blog.sin ...
 - ubuntu14.04下配置使用openCV3.0
			
[操 作 系 统] Ubuntu 14.04 LTS [OpenCV版本] 3.0.0-beta [Eclipse 版 本] 3.8.1 需要知识: Linux系统shell命令基础 编译原理 ...
 - 分享一个TP5实现Create()方法的心得
			
在TP5中发现用不了以前3.X的Create()方法,虽然用input更严谨,但是字段比较多的话还是有些不艺术的3.X中的实现方法如下: $Model = D('User'); $Model-> ...
 - c++子类调用基类方法的一个例子
			
Base.h #pragma once class Base { public: Base(void); ~Base(void); bool CreatClone( ...