From f8b9ca177fceaa691717f79a56123755dcf834ee Mon Sep 17 00:00:00 2001 From: Deven <63876261+devenperez@users.noreply.github.com> Date: Sun, 28 May 2023 18:57:00 -0400 Subject: [PATCH] Time: 6 ms (55.93%), Space: 6.2 MB (98.14%) - LeetHub --- .../83-remove-duplicates-from-sorted-list.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 83-remove-duplicates-from-sorted-list/83-remove-duplicates-from-sorted-list.c 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