83--Remove Duplicates From Sorted List

public class RemoveDuplicatesFromSortedList {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode current=head;
        while (current!=null&&current.next!=null){
            if (current.val==current.next.val)
                current.next=current.next.next;
            else
                current=current.next;
        }
        return head;
    }
}

 

上一篇:php – 在Array中查找并替换重复项


下一篇:android UI进阶之用【转】