我的javascript代码


  • 0
    W

    var deleteDuplicates = function(head) {
    if(!head||!head.next)return head;
    var sentional=new ListNode(0),la=head,lb=head.next;
    sentional.next=head;
    var start=sentional;
    while(lb){
    if(la.val===lb.val){
    while(lb&&(lb.val==la.val)){
    lb=lb.next?lb.next:null;
    }
    if(!lb){
    start.next=null;
    break;
    }
    start.next=lb;
    la=lb;
    lb=lb.next?lb.next:null;
    continue;
    }
    lb=lb.next?lb.next:null;
    la=la.next?la.next:null;
    start=start.next?start.next:null;
    }
    return sentional.next;
    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.