首页 > 其他 > 详细

83. Remove Duplicates from Sorted List

时间:2016-04-01 07:57:48      阅读:160      评论:0      收藏:0      [点我收藏+]
 1     public ListNode deleteDuplicates(ListNode head) {
 2         if(head == null) {
 3             return null;
 4         }
 5         ListNode dummy = new ListNode(-1);
 6         dummy.next = head;
 7         while(head != null && head.next != null) {
 8             if(head.val == head.next.val) {
 9                 head.next = head.next.next;
10             } else {
11                 head = head.next;
12             }
13         }
14         return dummy.next;
15     }

第10行是else,不是每次执行,这样连续重复数字才能被处理

83. Remove Duplicates from Sorted List

原文:http://www.cnblogs.com/warmland/p/5343571.html

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