LintCode(452)
来源:互联网 发布:淘宝助理mac 编辑:程序博客网 时间:2024/05/16 12:05
Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.
样例
Given 1->2->3->3->4->5->3, val = 3, you should return the list as 1->2->4->5
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public class Solution { /** * @param head a ListNode * @param val an integer * @return a ListNode */ public ListNode removeElements(ListNode head, int val) { // Write your code here //ListNode p = new ListNode(0); ListNode dummy = new ListNode(0); dummy.next = head; head = dummy; while(head.next != null){ if(head.next.val == val) head.next = head.next.next; else head = head.next; } return dummy.next; } }
0 0
- LintCode(452)
- LintCode
- lintcode--
- lintcode
- LintCode
- Lintcode
- lintcode-Remove Linked List Elements-452
- LintCode 452 删除链表中的元素
- lintcode 452 删除链表中的元素
- LintCode:删除链表中的元素452
- [Lintcode] #452 删除链表中的元素
- LintCode 第452题 删除链表中的元素
- (lintcode)第452题删除链表中的元素
- 【LintCode-452】删除链表中的元素(Java实现)
- LintCode 第452题 删除链表中的元素
- Lintcode - Median
- Lintcode - MedianII
- Lintcode - Heapify
- 黑马程序员--集合(上)
- 字符串数组
- 大数据技术——storm(Topology)
- 71道安卓面试题
- ListNode
- LintCode(452)
- 工作笔记之“android adb 常用命令”
- Mean Shift算法介绍
- hdu2196 Compute
- linux下运行java代码
- npm ERR! tar.unpack untar error
- python 实现 九九乘法表【eclipse 编辑器】
- 64位的win7配置python、pip、numpy、scipy、matplotlib
- Python list 操作