【LeetCode从零单排】No83 Remove Duplicates from Sorted List
来源:互联网 发布:qq视频录像软件注册码 编辑:程序博客网 时间:2024/04/30 15:34
题目
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given 1->1->2
, return 1->2
.
Given 1->1->2->3->3
, return 1->2->3
.
代码
public static ListNode deleteDuplicates(ListNode head) { if (head==null || head.next==null) return head; ListNode first = head; ListNode second=head.next; while(second!=null){ if(first.val==second.val){ second=second.next; first.next=second; } else{ first=first.next; second=first.next; } } return head; }
代码下载:https://github.com/jimenbian/GarvinLeetCode
/********************************
* 本文来自博客 “李博Garvin“
* 转载请标明出处:http://blog.csdn.net/buptgshengod
******************************************/
0 0
- 【LeetCode从零单排】No83 Remove Duplicates from Sorted List
- leetcode No83. Remove Duplicates from Sorted List
- 【LeetCode从零单排】No26.Remove Duplicates from Sorted Array
- 【leetcode每日一题】NO83.Remove Duplicates from Sorted List
- 【LeetCode从零单刷】Remove Duplicates from Sorted List
- Remove Duplicates from Sorted List :from LeetCode
- Leetcode - List - Remove Duplicates from Sorted List
- [leetcode][list] Remove Duplicates from Sorted List
- [leetcode][list] Remove Duplicates from Sorted List
- LeetCode: Remove Duplicates from Sorted List
- LeetCode: Remove Duplicates from Sorted List II
- [Leetcode] Remove Duplicates from Sorted List
- [Leetcode] Remove Duplicates from Sorted List II
- LeetCode: Remove Duplicates from Sorted List
- LeetCode: Remove Duplicates from Sorted List II
- [Leetcode] Remove Duplicates from Sorted List II
- leetcode 37: Remove Duplicates from Sorted List
- [leetcode] Remove Duplicates from Sorted List II
- android 大尺寸图片处理
- 一元二次方程求解
- IDR机制
- Eclipse 操作Hbase 代码一
- 读《烽烟中的敏捷》有感
- 【LeetCode从零单排】No83 Remove Duplicates from Sorted List
- fgets()学习
- android bitmap缓存机制(下)
- JAVA技术路线图
- Request的getParameter和getAttribute方法的区别
- DBus 入门与应用 -- DBus 的 C 编程接口
- IDR--Integer ID Management
- ubuntu14.04交叉编译vlc2.1.5源码,编译出在win32下运行的程序
- word2vec