【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 ...
随机推荐
- django(五)
URLs 当一个用户请求一个页面时,Django将按照顺序去匹配每一个模式,并停在第一个匹配请求的URL上. 如果你的url多个正则表达式都能匹配上咋弄?小心出错,这个是按照顺序匹配的 url(r'^ ...
- iOS软件开发架构理解
这个东西是硬伤,框架?自带的mvc? 自带的UIViewController UIView UINavigationController 这些算不算?当然算的,cocoa框架嘛,大家都知道. 其实,我 ...
- TabCtrl的基本用法
MFC TabCtrl控件的使用方法及思路 1.建立基于Dialog的应用程序 2.添加TabCtrl控件,并关联变量 3.建立TabCtrl中存放的Dialog子对话框若干,并关联类 4.在Tabc ...
- [转]分享一个用Telnet代替JLinkRTTClient的办法,实现同时显示和记录
原帖子http://www.amobbs.com/thread-5614514-1-1.html Jlink 驱动 升级到4.96后,提供了一个 JLinkRTTViewer,确实方便了很多,但似乎不 ...
- golang 格式化时间为字符串
package main import ( "fmt" "reflect" "time" ) func main() { //格式化字符串为 ...
- LESS与SASS的伯与仲
工作中用到了Bootstrap,涉及到了LESS,对其做了一个简单的了解,CSS的预处理器使用最广泛的就是LESS和Sass,都是努力把CSS武装成为开发语言,让它从简单的描述性语言过渡到具有程序式特 ...
- jqeury datatable
1.自定义列信息 "aoColumnDefs":[ { ...
- linux获取系统启动时间
1.前言 时间对操作系统来说非常重要,从内核级到应用层,时间的表达方式及精度各部相同.linux内核里面用一个名为jiffes的常量来计算时间戳.应用层有time.getdaytime等函数.今天需要 ...
- 转 Eric Raymond对于几大开发语言的评价
原文见:http://blog.jobbole.com/79421/ [译注]:Eric Raymond是开源运动的领袖人物,对于UNIX开发有很深的造诣,主持开发了fetchmail.他的<大 ...
- myeclipse中Web App Libraries无法自动识别lib下的jar包
在项目目录下找到.object文件修改 <natures> <nature>org.eclipse.jem.workbench.JavaEMFNature</nature ...