题解 | #删除有序链表中重复的元素-II#

删除有序链表中重复的元素-II

http://www.nowcoder.com/practice/71cef9f8b5564579bf7ed93fbe0b2024

struct ListNode* deleteDuplicates(struct ListNode* head ) {
    // write code here
    if(head==NULL)
        return head;
    struct ListNode* H=malloc(sizeof(struct ListNode));
    H->next=head;
    struct ListNode* cur=H;
    while(cur->next->next!=NULL&&cur->next!=NULL)
    {
        if(cur->next->val==cur->next->next->val)
        {
            int n=cur->next->val;
            while(n==cur->next->val&&cur->next!=NULL)
            {
                cur->next=cur->next->next;   
            }
        }
        else
        {
            cur=cur->next;    
        }
    }
    return H->next;
}
全部评论

相关推荐

敢逐云霄志:你打招呼语怎么能这么长,hr都没看下去的欲望,简明扼要说重点,就读于某某学校某某专业,26届应届毕业生,学信网可查,先后在某某公司实习过(如有),然后做过什么项目,想找一份什么样的工作,可实习几个月以上,期待您的回复。
点赞 评论 收藏
分享
在笔试的大西瓜很矫健:这跟数分八竿子打不着,先去了解实习要会什么再说找实习吧
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务