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;
    }
}

 

posted @ 2019-09-08 10:55 张玉昊 阅读(...) 评论(...) 编辑 收藏