首页 > 系统服务 > 详细

VMware Coding Challenge: Removing Duplicates Entries

时间:2015-03-07 06:14:38      阅读:388      评论:0      收藏:0      [点我收藏+]

技术分享

 

 1     static LinkedListNode removeDuplicates(LinkedListNode list) {
 2         LinkedListNode cur = list;
 3         HashSet<Integer> set = new HashSet<Integer>();
 4         set.add(list.val);
 5         while (cur.next != null) {
 6             if (!set.contains(cur.next.val)) {
 7                 set.add(cur.next.val);
 8                 cur = cur.next;
 9             }
10             else {
11                 cur.next = cur.next.next;
12             }
13         }
14         return list;
15 
16     }

 

VMware Coding Challenge: Removing Duplicates Entries

原文:http://www.cnblogs.com/EdwardLiu/p/4319663.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!