{"id":2541,"date":"2022-02-02T17:17:24","date_gmt":"2022-02-02T09:17:24","guid":{"rendered":"http:\/\/139.9.1.231\/?p=2541"},"modified":"2022-02-02T17:17:25","modified_gmt":"2022-02-02T09:17:25","slug":"leetcodeday82","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/02\/02\/leetcodeday82\/","title":{"rendered":"leetcodeday82 &#8211;\u5220\u9664\u6392\u5e8f\u94fe\u8868\u4e2d\u7684\u91cd\u590d\u5143\u7d20 II"},"content":{"rendered":"\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u5df2\u6392\u5e8f\u7684\u94fe\u8868\u7684\u5934&nbsp;<code>head<\/code>&nbsp;\uff0c&nbsp;<em>\u5220\u9664\u539f\u59cb\u94fe\u8868\u4e2d\u6240\u6709\u91cd\u590d\u6570\u5b57\u7684\u8282\u70b9\uff0c\u53ea\u7559\u4e0b\u4e0d\u540c\u7684\u6570\u5b57<\/em>&nbsp;\u3002\u8fd4\u56de&nbsp;<em>\u5df2\u6392\u5e8f\u7684\u94fe\u8868<\/em>&nbsp;\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><img src=\"https:\/\/assets.leetcode.com\/uploads\/2021\/01\/04\/linkedlist1.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>head = &#91;1,2,3,3,4,4,5]\n<strong>\u8f93\u51fa\uff1a<\/strong>&#91;1,2,5]<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><img src=\"https:\/\/assets.leetcode.com\/uploads\/2021\/01\/04\/linkedlist2.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>head = &#91;1,1,1,2,3]\n<strong>\u8f93\u51fa\uff1a<\/strong>&#91;2,3]<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code># &#91;82] \u5220\u9664\u6392\u5e8f\u94fe\u8868\u4e2d\u7684\u91cd\u590d\u5143\u7d20 II\r\n#\r\n\r\n# @lc code=start\r\n# Definition for singly-linked list.\r\n# class ListNode:\r\n#     def __init__(self, val=0, next=None):\r\n#         self.val = val\r\n#         self.next = next\r\nclass Solution:\r\n    def deleteDuplicates(self, head: ListNode) -> ListNode:\r\n        if not head:\r\n            return head\r\n        \r\n        dummy = ListNode(0, head)\r\n\r\n        cur = dummy\r\n        while cur.next and cur.next.next:\r\n            if cur.next.val == cur.next.next.val:\r\n                x = cur.next.val\r\n                while cur.next and cur.next.val == x:\r\n                    cur.next = cur.next.next\r\n            else:\r\n                cur = cur.next\r\n\r\n        return dummy.next\r\n\r\n\r\n\r\n# @lc code=end<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"894\" height=\"231\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-13.png\" alt=\"\" class=\"wp-image-2542\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-13.png 894w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-13-300x78.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-13-768x198.png 768w\" sizes=\"(max-width: 894px) 100vw, 894px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u5b9a\u4e00\u4e2a\u5df2\u6392\u5e8f\u7684\u94fe\u8868\u7684\u5934&nbsp;head&nbsp;\uff0c&nbsp;\u5220\u9664\u539f\u59cb\u94fe\u8868\u4e2d\u6240\u6709\u91cd\u590d\u6570\u5b57\u7684\u8282\u70b9\uff0c\u53ea\u7559\u4e0b &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/02\/02\/leetcodeday82\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday82 &#8211;\u5220\u9664\u6392\u5e8f\u94fe\u8868\u4e2d\u7684\u91cd\u590d\u5143\u7d20 II<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2541"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=2541"}],"version-history":[{"count":1,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2541\/revisions"}],"predecessor-version":[{"id":2543,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2541\/revisions\/2543"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=2541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=2541"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=2541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}