leetcode:Remove Duplicates from Sorted List
来源:互联网 发布:ubuntu更新软件的方法 编辑:程序博客网 时间:2024/05/16 10:24
去除链表中重复的元素并只保留一个
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */public class Solution { public ListNode deleteDuplicates(ListNode head) { if(head != null && head.next != null){ ListNode pre = head, next = head.next; while(next != null){ while(next != null && pre.val == next.val){ next = next.next; } pre.next = next; pre = next; if(pre != null) next = pre.next; } } return head; }}
0 0
- 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
- [LeetCode] Remove Duplicates from Sorted List II
- [LeetCode] Remove Duplicates from Sorted List
- [leetcode] Remove Duplicates from Sorted List
- [leetcode] Remove Duplicates from Sorted List II
- [LeetCode]Remove Duplicates from Sorted List
- 浅谈java中的集合类
- 格式化命令行参数getopt和getopts的使用
- DLL 实现单元
- 【unix网络编程】4-11显示客户IP地址和端口号的时间获取服务程序
- Codeforces 443A Anton and Letters(水题)
- leetcode:Remove Duplicates from Sorted List
- Android笔记之 Web Service 基础
- qSort implemented in recursion and non-recuision version
- Codeforces 19D Points 线段树+set
- The Problems of zoj By watashi
- (转)logback 配置详解(一)
- 如何判断两个链表相交及找到第一个相交点
- 关于S3C2440de6410的CPU,关于FPU方面的配置
- IO(二)