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 ...
随机推荐
- Golang之写一个聊天室
. 海量用户在线聊天系统 . 点对点聊天 . 用户登录&注册 一.服务端开发 . 用户管理 用户id:数字 用户密码:字母数字组合 用户昵称:用来显示 用户性别:字符串 用户头像:url 用户 ...
- win, cmd下安装mysql(win真tm难用)
常用命令: 修改root用户密码 update mysql.user set authentication_string=password('1234qwer') where user='root' ...
- TPshop学习
笔记大纲: tpshop目录结构 功能模块 函数库 重要配置 助手函数 插件 模板 1.TPshop目录结构 目录结构(来自官方视频截图) 看这个图,目录结构一目了然.下面要讲的内容也是根据这个图展开 ...
- PAT 1010 一元多项式求导 (25)(STL-map+思路)
1010 一元多项式求导 (25)(25 分)提问 设计函数求一元多项式的导数.(注:x^n^(n为整数)的一阶导数为n*x^n-1^.) 输入格式:以指数递降方式输入多项式非零项系数和指数(绝对值均 ...
- 2.自己搭建的一个简易的ioc容器
1.persondao类namespace MyselfIoC{ public class PersonDao { public override string ToStri ...
- Mybatis Blob和String互转,实现文件上传等。
这样的代码网上有很多,但是本人亲测有bug, 下面是我写的代码.望参考 @MappedJdbcTypes(JdbcType.BLOB) public class BlobAndStringTypeHa ...
- 2018秋季c语言基础课第一次作业
1)大学和高中最大的不同是没有人天天看着你,请看大学理想的师生关系是?有何感想? 答:邹欣老师提到了很多种关系,不外呼就是两种:平等或者不平等.平等的师生关系与陌生人无异,而自古以来尊师重道却被世人所 ...
- kbmMWEncodeEscapes 中汉字编码的问题及解决办法
kbmMWEncodeEscapes 是kbmmw 里面的一个函数,用来对URL 中的汉字进行编码,例如 http://127.0.0.1/getname?name=春节,由于'春节'是汉字,浏览器向 ...
- 2018.10.18 bzoj1185: [HNOI2007]最小矩形覆盖(旋转卡壳)
传送门 不难看出最后的矩形一定有一条边与凸包某条边重合. 因此先求出凸包,然后旋转卡壳求出当前最小矩形面积更新答案. 代码: #include<bits/stdc++.h> #define ...
- 2018.09.17 atcoder Tak and Cards(背包)
传送门 背包经典题. 直接f[i][j]f[i][j]f[i][j]表示选i张牌和为j的方案数. 最后统计答案就行了. 代码: #include<bits/stdc++.h> #defin ...