LeetCode 203 Remove Linked List Elements
2016-03-30 15:59
399 查看
Remove all elements from a linked list of integers that have value val.
Example
Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6
Return: 1 --> 2 --> 3 --> 4 --> 5
Example
Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6
Return: 1 --> 2 --> 3 --> 4 --> 5
public ListNode removeElements(ListNode head, int val) { ListNode cur = new ListNode(-1); cur.next = head; ListNode tmp = cur; while (cur.next != null) { if (cur.next.val == val) cur.next = cur.next.next; else cur = cur.next; } return tmp.next; }
相关文章推荐
- OSI、TCP/IP参考模型对应的网络协议
- 汉诺塔问题:64个盘子,3个基座A、B、C,编程打印处移动过程
- 如何在github中创建演示demo
- oracle 11g RAC手动卸载grid,no deinstall .
- CentOS7 keepalive+nginx高可用配置
- linux下文件的一些特性的判断方法
- daratable Api,随记
- 10张思维导图带你学习JavaScript
- 介绍,介绍我的底层支持库 Net.Sz.CFramework
- 神经网络模型算法与生物神经网络的最新联系
- bzoj3594&&方伯伯的玉米田
- MySQL――修改root密码的4种方法(以windows为例)
- 美图欣赏,转载[原文链接http://toutiao.com/a4001258776/]
- cengos 安装redis 并将redis启动添加为系统服务
- Android 系统服务一览
- EF CodeFirst Mirgration
- 网易16年春季实习生招聘的一道算法题
- Mysql在大型网站的应用架构演变
- LNMP(linux+nginx+mysql+php)服务器环境配置
- 原生javascript实现的一个简单动画效果