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.
class Solution {
public:
void deleteNode(ListNode* node) {
if (node == NULL) {}
else {
ListNode* tmp = node->next;
node->val = tmp->val;
node->next = tmp->next;
delete tmp;
}
}
};
Linked List-237. Delete Node in a Linked List的更多相关文章
- 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 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 ...
- 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. 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 ...
- 【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 ...
- 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 ...
- 237. Delete Node in a Linked List(leetcode)
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
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Write a ...
随机推荐
- How to set an Apache Kafka multi node – multi broker cluster【z】
Set a multi node Apache ZooKeeper cluster On every node of the cluster add the following lines to th ...
- css布局---各种居中
居中是我们使用css来布局时常遇到的情况.使用css来进行居中时,有时一个属性就能搞定,有时则需要一定的技巧才能兼容到所有浏览器,本文就居中的一些常用方法做个简单的介绍. 注:本文所讲方法除了特别说明 ...
- 761A Dasha and Stairs
A. Dasha and Stairs time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- makefile all
all:udps udpc udps:udpserv.c gcc -Wall -o udps udpserv.cudpc:udpclient.c gcc -Wall -o udpc udp ...
- 16款值得一用的iPhone线框图模板 (PSD & Sketch)
在任何网站或移动应用设计的过程中,线框图作为设计元素和功能的图示,它有助于帮助定义和更好地传达信息层次结构,让参与设计和开发的人员更好的理解设计师的思路和设计的功能点. 即使线框图设计是一个比较耗时的 ...
- connect strings sql server
https://www.connectionstrings.com/sql-server/ Server=myServerAddress[,port];Database=myDataBase;User ...
- Javascript 常用扩展方法
这篇文章纯粹是为了保存这些方法,供以后翻阅,其实一直保存在 evernote 里面,但觉得还是放到对的地方会好点. 现在收录的很少,希望以后会慢慢增多. 数组扩展 contains,remove 扩展 ...
- ORACLE 查看分区表分区大小
SELECT * FROM dba_segments t WHERE t.segment_name ='table_name'; pratition_name : 分区名 bytes : 分区大小( ...
- 2018.09.19 atcoder Snuke's Coloring(思维题)
传送门 谁能想到这道题会写这么久. 本来是一道很sb的题啊. 就是每次选一个点只会影响到周围的九个方格,随便1e9进制就可以hash了,但是我非要作死用stl写. 结果由于技术不够高超,一直调不出来. ...
- linux CentOS 7 安装 RabbitMQ Erlang 21.0
1. 安装erlang 安装依赖环境 yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel unixO ...