From 865e68bc485ac76f82892208d4c625f464282cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=96=9C=E6=AC=A2=E5=81=9A=E7=99=BD=E6=97=A5=E6=A2=A6?= <760721316@qq.com> Date: Sat, 4 Nov 2023 07:55:55 +0000 Subject: [PATCH] =?UTF-8?q?add=202109020142/chapter2/=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E9=93=BE=E8=A1=A8=E4=B8=AD=E7=9A=84=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E5=85=83=E7=B4=A02.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 喜欢做白日梦 <760721316@qq.com> --- ...\215\345\244\215\345\205\203\347\264\2402" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "2109020142/chapter2/\345\210\240\351\231\244\346\216\222\345\272\217\351\223\276\350\241\250\344\270\255\347\232\204\351\207\215\345\244\215\345\205\203\347\264\2402" diff --git "a/2109020142/chapter2/\345\210\240\351\231\244\346\216\222\345\272\217\351\223\276\350\241\250\344\270\255\347\232\204\351\207\215\345\244\215\345\205\203\347\264\2402" "b/2109020142/chapter2/\345\210\240\351\231\244\346\216\222\345\272\217\351\223\276\350\241\250\344\270\255\347\232\204\351\207\215\345\244\215\345\205\203\347\264\2402" new file mode 100644 index 00000000..4ab020ff --- /dev/null +++ "b/2109020142/chapter2/\345\210\240\351\231\244\346\216\222\345\272\217\351\223\276\350\241\250\344\270\255\347\232\204\351\207\215\345\244\215\345\205\203\347\264\2402" @@ -0,0 +1,22 @@ +struct ListNode* deleteDuplicates(struct ListNode* head) { + if (!head) { + return head; + } + + struct ListNode* dummy = malloc(sizeof(struct ListNode)); + dummy->next = head; + + struct ListNode* cur = dummy; + while (cur->next && cur->next->next) { + if (cur->next->val == cur->next->next->val) { + int x = cur->next->val; + while (cur->next && cur->next->val == x) { + cur->next = cur->next->next; + } + } else { + cur = cur->next; + } + } + + return dummy->next; +} \ No newline at end of file -- Gitee