题目:
![](https://img-blog.csdnimg.cn/img_convert/7a0e57aab890559036ee3cf13c701bbf.png)
解答:
class Solution {
public ListNode deleteDuplicates(ListNode head) {
if(head == null){
return head;
}
ListNode index = head;
while(index.next != null){
if(index.next.val == index.val){
index.next = index.next.next;
}else{
index = index.next;
}
}
return head;
}
}
![](https://img-blog.csdnimg.cn/img_convert/d4dc0a24efc6ded9f22ccdc1b2608cf6.png)