Skip to content

Commit

Permalink
Add 05.cc
Browse files Browse the repository at this point in the history
  • Loading branch information
pin3da authored Jan 5, 2021
1 parent 0d2be7e commit ac8e7bb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions solved/LeetCode/Challenges/2020/January/05.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Solution {
public:
ListNode* deleteDuplicates(ListNode* head) {
if ((head == nullptr) || (head->next == nullptr)) {
return head;
}
int t = head->next->val;
if (head->val != t) {
head->next = deleteDuplicates(head->next);
return head;
}
while (head != nullptr && head->val == t) {
head = head->next;
}
return deleteDuplicates(head);
}
};

0 comments on commit ac8e7bb

Please sign in to comment.