{"id":2643,"date":"2023-10-16T11:49:15","date_gmt":"2023-10-16T03:49:15","guid":{"rendered":"https:\/\/white-night.club\/?p=2643"},"modified":"2023-11-09T11:07:49","modified_gmt":"2023-11-09T03:07:49","slug":"ad60","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/16\/ad60\/","title":{"rendered":"83.\u00a0\u5220\u9664\u6392\u5e8f\u94fe\u8868\u4e2d\u7684\u91cd\u590d\u5143\u7d20"},"content":{"rendered":"\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u5df2\u6392\u5e8f\u7684\u94fe\u8868\u7684\u5934\u00a0<code>head<\/code>\u00a0\uff0c\u00a0<em>\u5220\u9664\u6240\u6709\u91cd\u590d\u7684\u5143\u7d20\uff0c\u4f7f\u6bcf\u4e2a\u5143\u7d20\u53ea\u51fa\u73b0\u4e00\u6b21<\/em>\u00a0\u3002\u8fd4\u56de\u00a0<em>\u5df2\u6392\u5e8f\u7684\u94fe\u8868<\/em>\u00a0\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><img decoding=\"async\" alt=\"\" src=\"https:\/\/assets.leetcode.com\/uploads\/2021\/01\/04\/list1.jpg\"><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>head = [1,1,2]\n<strong>\u8f93\u51fa\uff1a<\/strong>[1,2]\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><img decoding=\"async\" alt=\"\" src=\"https:\/\/assets.leetcode.com\/uploads\/2021\/01\/04\/list2.jpg\"><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>head = [1,1,2,3,3]\n<strong>\u8f93\u51fa\uff1a<\/strong>[1,2,3]\n<\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li>\u94fe\u8868\u4e2d\u8282\u70b9\u6570\u76ee\u5728\u8303\u56f4&nbsp;<code>[0, 300]<\/code>&nbsp;\u5185<\/li>\n\n\n\n<li><code>-100 &lt;= Node.val &lt;= 100<\/code><\/li>\n\n\n\n<li>\u9898\u76ee\u6570\u636e\u4fdd\u8bc1\u94fe\u8868\u5df2\u7ecf\u6309\u5347\u5e8f&nbsp;<strong>\u6392\u5217<\/strong><\/li>\n<\/ul>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>\u94fe\u8868<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u56de\u987e\u4e00\u4e0b\u94fe\u8868\u9898\u3002\u592a\u4e45\u6ca1\u5199\u4e0d\u80fd\u5fd8\u4e86\u3002<\/p>\n\n\n\n<p>\u672c\u6765\u50cf\u5efa\u4e2adummy\u8282\u70b9\u7684\uff0c\u4f46\u662f\u518d\u4ed4\u7ec6\u60f3\u4e0b\uff0c\u53c8\u4e0d\u7528\u5220\u9664\u5934\u8282\u70b9\uff0c\u56e0\u4e3a\u53ea\u662f\u5220\u9664\u201c\u67d0\u4e2a\u5143\u7d20\u91cd\u590d\u7684\u90e8\u5206\u201d\uff0c\u800c\u4e0d\u662f\u5220\u9664\u201c\u6709\u51fa\u73b0\u91cd\u590d\u7684\u5143\u7d20\u201d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\r\n * Definition for singly-linked list.\r\n * struct ListNode {\r\n *     int val;\r\n *     ListNode *next;\r\n *     ListNode() : val(0), next(nullptr) {}\r\n *     ListNode(int x) : val(x), next(nullptr) {}\r\n *     ListNode(int x, ListNode *next) : val(x), next(next) {}\r\n * };\r\n *\/\r\nclass Solution {\r\npublic:\r\n    ListNode* deleteDuplicates(ListNode* head) {\r\n        if(head==NULL)\r\n            return head;\r\n\r\n        ListNode*cur=head;\r\n        while(cur!=NULL&amp;&amp;cur->next!=NULL)\r\n        {\r\n            if(cur->val==cur->next->val)\r\n            {\r\n                cur->next=cur->next->next;\r\n            }else\r\n            {\r\n                cur=cur->next;\r\n            }\r\n        }\r\n        return head;\r\n    }\r\n};<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u94fe\u8868\u5220\u9664\u5143\u7d20<\/p>\n","protected":false},"author":1,"featured_media":2827,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[42,25],"tags":[38],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2643"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=2643"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2643\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/2827"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=2643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}