Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given 1->1->2, return 1->2.
Given 1->1->2->3->3, return 1->2->3.
这个题就没什么好说的了
现在简单题尽量不用ide,直接在网页上写
public ListNode deleteDuplicates(ListNode head) {
ListNode p = head;
while(p!=null && p.next != null){
if(p.val == p.next.val){
p.next = p.next.next;
continue;
}
p = p.next;
}
return head;
}