标签:
看了别人讨论,双指针比较方便http://www.cnblogs.com/springfor/p/3862042.html
public class Solution { public ListNode deleteDuplicates(ListNode head) { if(head==null|| head.next==null) return head; ListNode h = new ListNode(-1); h.next = head; ListNode l1 = head; ListNode l2 = l1.next; while(l2!=null){ while(l2!=null && l1.val==l2.val){ l2 = l2.next; } l1.next = l2; l1=l1.next; } return h.next; } }
Remove Duplicates from Sorted List
标签:
原文地址:http://www.cnblogs.com/jiajiaxingxing/p/4401279.html