MCPcopy Create free account
hub / github.com/Ainevsia/Leetcode-Rust / Solution

Class Solution

82. Remove Duplicates from Sorted List II/Solution.cpp:10–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8};
9
10class Solution {
11public:
12 ListNode* deleteDuplicates(ListNode* head) {
13 if (head == NULL || head->next == NULL) return head;
14 auto p = head, c = head->next;
15 while (c != NULL && p->val == c->val) c = c->next;
16 if (c != p->next) return this->deleteDuplicates(c);
17 auto rest = this->deleteDuplicates(c);
18 p->next = rest;
19 return p;
20 }
21};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected