diff --git a/83-remove-duplicates-from-sorted-list/83-remove-duplicates-from-sorted-list.c b/83-remove-duplicates-from-sorted-list/83-remove-duplicates-from-sorted-list.c new file mode 100644 index 0000000..3a58c61 --- /dev/null +++ b/83-remove-duplicates-from-sorted-list/83-remove-duplicates-from-sorted-list.c @@ -0,0 +1,22 @@ +/** + * Definition for singly-linked list. + * struct ListNode { + * int val; + * struct ListNode *next; + * }; + */ +struct ListNode* deleteDuplicates(struct ListNode* head){ + struct ListNode *current = head; + while (current) { + struct ListNode *next = current->next; + + while (next && current->val == next->val) { + next = next->next; + } + + current->next = next; + current = next; + } + return head; + +} \ No newline at end of file