问题
关键:利用两个栈来构成一个队列
struct ListNode* deleteDuplication(struct ListNode* head) {
if(!head) return;
struct ListNode * dummy = (struct ListNode*)malloc(sizeof(struct ListNode*));
dummy->next = head;
struct ListNode * pre = dummy;
struct ListNode * cur = head;
while(cur){
while(cur && pre->next->val == cur->val) cur = cur->next; //分两种情况,具体可画图看
if(pre->next->next == cur) pre = pre->next; //上一段while过程没有重复节点
else pre->next = cur;
}
return dummy->next;
}