diff --git a/solved/LeetCode/Challenges/2020/January/05.cc b/solved/LeetCode/Challenges/2020/January/05.cc new file mode 100644 index 00000000..022ea9ea --- /dev/null +++ b/solved/LeetCode/Challenges/2020/January/05.cc @@ -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); + } +};