83. 删除排序链表中的重复元素

1
2
3
4
5
6
7
8
9
10
11
12
13
class Solution {
public ListNode deleteDuplicates(ListNode head) {
ListNode pre = head;
while(pre!=null && pre.next != null){
if(pre.next.val == pre.val){
pre.next = pre.next.next;
}else{
pre = pre.next;
}
}
return head;
}
}