删除链表中重复节点(递归)
代码语言:javascript复制public ListNode deleteDuplication(ListNode pHead){
if(pHead == null || pHead.next == null)
return pHead;
ListNode current = pHead.next;
// 如果是重复元素
if(pHead.val == current.val){
current = current.next;
while(current != null && current.val == pHead.val)
current = current.next;
pHead = current;
return deleteDuplication(current);
}else{
// pHead不是重复元素
pHead.next = deleteDuplicaton(current);
return pHead;
}
}