/*
* function ListNode(x){
* this.val = x;
* this.next = null;
* }
*/
/**
*
* @param head ListNode类
* @return ListNode类
*/
function deleteDuplicates( head ) {
// write code here
if(!head)return null;
let p=head,q;
while(p!=null&&p.next){
if(p&&!p.next)return p;
q=p.next;
if(p.val==q.val){
p.next=q.next;
q=null;
}else{
p=p.next;
}
}
return head;
}
module.exports = {
deleteDuplicates : deleteDuplicates
};
* function ListNode(x){
* this.val = x;
* this.next = null;
* }
*/
/**
*
* @param head ListNode类
* @return ListNode类
*/
function deleteDuplicates( head ) {
// write code here
if(!head)return null;
let p=head,q;
while(p!=null&&p.next){
if(p&&!p.next)return p;
q=p.next;
if(p.val==q.val){
p.next=q.next;
q=null;
}else{
p=p.next;
}
}
return head;
}
module.exports = {
deleteDuplicates : deleteDuplicates
};