We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent edb0def commit 88cce13Copy full SHA for 88cce13
remove-duplicates-from-sorted-list-ii.c
@@ -0,0 +1,34 @@
1
+/**
2
+ * Definition for singly-linked list.
3
+ * struct ListNode {
4
+ * int val;
5
+ * struct ListNode *next;
6
+ * };
7
+ */
8
+struct ListNode* deleteDuplicates(struct ListNode* head) {
9
+ struct ListNode root;
10
+ struct ListNode *prev,*tmp;
11
+ int start_val;
12
+ int count;
13
+
14
+ root.next = NULL;
15
+ prev = &root;
16
+ while(head)
17
+ {
18
+ start_val = head->val;
19
+ count = 1;
20
+ while(head->next && head->next->val == start_val){
21
+ ++count;
22
+ head = head->next;
23
+ }
24
+ tmp = head->next;
25
+ if(count == 1){
26
+ head->next = prev->next;
27
+ prev->next = head;
28
+ prev = head;
29
30
+ head = tmp;
31
32
33
+ return root.next;
34
+}
0 commit comments