• LeetCode Remove Duplicates from Sorted List II


    // 60ms
    1
    /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * }; 8 */ 9 class Solution { 10 public: 11 ListNode *deleteDuplicates(ListNode *head) { 12 // Start typing your C/C++ solution below 13 // DO NOT write int main() function 14 ListNode temp(0); 15 ListNode *q,*p; 16 17 18 q=&temp; 19 q->next=head; 20 p=head; 21 22 while(p) 23 { 24 if(p->next&&p->val==p->next->val) 25 { 26 while(p->next&&p->val==p->next->val) 27 { 28 p->next=p->next->next; 29 q->next=p->next; 30 } 31 } 32 else 33 { 34 q=p; 35 } 36 p=p->next; 37 } 38 return temp.next; 39 } 40 };
  • 相关阅读:
    1.表单标签
    07.Ajax.post
    06.Ajax.get
    05.Ajax.get
    04.Ajax-get.html
    03.post.file
    nodejs-7.2. CURD数据管理系统小栗子
    nodejs-7.1. mongoose模块
    JS 无缝轮播图1-节点操作
    JS 放大镜特效
  • 原文地址:https://www.cnblogs.com/mengqingzhong/p/3118558.html
Copyright © 2020-2023  润新知