zoukankan      html  css  js  c++  java
  • LeetCode() Remove duplicates from sorted list II

     ListNode* dummy = new ListNode(0); //必须要加上 new ListNode(0); 否则有错误。
            dummy->next = head;
            head = dummy;
            while(head->next && head->next->next) {
                if(head->next->val == head->next->next->val) {
                    int value = head->next->val;
                    while(head->next && head->next->val == value) {
                        head->next = head->next->next;
                    }
                } else {
                    head = head->next;
                }
            }
            return dummy->next;

      有时候应换一种思路。

  • 相关阅读:
    Python lambda函数
    python 获取日期
    <base>元素
    django--开发博客
    django修改时区,数据库
    django初探
    python创建虚拟环境
    资源记录页面
    组管理
    远程管理命令
  • 原文地址:https://www.cnblogs.com/yanqi110/p/5003795.html
Copyright © 2011-2022 走看看