problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
acwing::acwing29::Solution类 参考

#include <acwing.h>

静态 Public 成员函数

static ListNodedeleteDuplication (ListNode *head)
 

详细描述

在文件 acwing.h1637 行定义.

成员函数说明

◆ deleteDuplication()

ListNode * acwing::acwing29::Solution::deleteDuplication ( ListNode head)
static

在文件 acwing.cpp5090 行定义.

5090 {
5091 if(head == nullptr) {
5092 return head;
5093 }
5094 while(head != nullptr && head->next != nullptr && head->val == head->next->val) {
5095 const int val = head->val;
5096 while(head != nullptr && head->val == val) {
5097 head = head->next;
5098 }
5099 }
5100 ListNode *ans = head;
5101 while(head != nullptr) {
5102 while(head->next != nullptr && head->next->next != nullptr && head->next->val == head->next->next->val) {
5103 const int val = head->next->val;
5104 ListNode *cursor = head->next;
5105 while(cursor != nullptr && cursor->val == val) {
5106 cursor = cursor->next;
5107 }
5108 head->next = cursor;
5109 }
5110 head = head->next;
5111 }
5112 return ans;
5113 }

该类的文档由以下文件生成: