Remove Duplicates from Sorted List II Posted on 2018-09-11 Descriptionhttps://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/description/ Solution12345678910111213141516171819202122232425262728293031323334353637/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */bool duplicate(struct ListNode* node) { if (node == NULL || node->next == NULL) return false; return node->val == node->next->val;}struct ListNode* deleteDuplicates(struct ListNode* head) { if (head == NULL || head->next == NULL) return head; struct ListNode* setinel_head = (struct ListNode* ) malloc(sizeof(struct ListNode)); setinel_head->next = head; struct ListNode* pre = setinel_head; struct ListNode* current = head; while (current != NULL) { if (duplicate(current) == false) { pre = pre->next; current = pre->next; }else { struct ListNode* nextNode = current->next; while (nextNode != NULL && current->val == nextNode->val){ nextNode = nextNode->next; } pre->next = nextNode; current = nextNode; } } return setinel_head->next;}