{"id":2360,"date":"2022-01-24T17:48:41","date_gmt":"2022-01-24T09:48:41","guid":{"rendered":"http:\/\/139.9.1.231\/?p=2360"},"modified":"2022-01-24T17:49:12","modified_gmt":"2022-01-24T09:49:12","slug":"leetcodeday83","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/01\/24\/leetcodeday83\/","title":{"rendered":"leetcodeday83 &#8211;\u5220\u9664\u6392\u5e8f\u94fe\u8868\u4e2d\u7684\u91cd\u590d\u5143\u7d20"},"content":{"rendered":"\n<p>\u5b58\u5728\u4e00\u4e2a\u6309\u5347\u5e8f\u6392\u5217\u7684\u94fe\u8868\uff0c\u7ed9\u4f60\u8fd9\u4e2a\u94fe\u8868\u7684\u5934\u8282\u70b9&nbsp;<code>head<\/code>&nbsp;\uff0c\u8bf7\u4f60\u5220\u9664\u6240\u6709\u91cd\u590d\u7684\u5143\u7d20\uff0c\u4f7f\u6bcf\u4e2a\u5143\u7d20&nbsp;<strong>\u53ea\u51fa\u73b0\u4e00\u6b21<\/strong>&nbsp;\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u540c\u6837\u6309\u5347\u5e8f\u6392\u5217\u7684\u7ed3\u679c\u94fe\u8868\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image is-style-default\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" src=\"https:\/\/assets.leetcode.com\/uploads\/2021\/01\/04\/list1.jpg\" alt=\"\" width=\"177\" height=\"142\"\/><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>head = &#91;1,1,2]\n<strong>\u8f93\u51fa\uff1a<\/strong>&#91;1,2]<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image is-style-default\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" src=\"https:\/\/assets.leetcode.com\/uploads\/2021\/01\/04\/list2.jpg\" alt=\"\" width=\"315\" height=\"129\"\/><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>head = &#91;1,1,2,3,3]\n<strong>\u8f93\u51fa\uff1a<\/strong>&#91;1,2,3]<\/code><\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul><li>\u94fe\u8868\u4e2d\u8282\u70b9\u6570\u76ee\u5728\u8303\u56f4\u00a0<code>[0, 300]<\/code>\u00a0\u5185<\/li><li><code>-100 &lt;= Node.val &lt;= 100<\/code><\/li><li>\u9898\u76ee\u6570\u636e\u4fdd\u8bc1\u94fe\u8868\u5df2\u7ecf\u6309\u5347\u5e8f\u6392\u5217<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># @lc app=leetcode.cn id=83 lang=python3\r\n#\r\n# &#91;83] \u5220\u9664\u6392\u5e8f\u94fe\u8868\u4e2d\u7684\u91cd\u590d\u5143\u7d20\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        head0=head\r\n        end=head\r\n        while end!=None:\r\n            if end.next!=None and head.val==end.next.val:\r\n                end=end.next\r\n            elif end.next!=None and head.val!=end.next.val:\r\n                head.next=end.next\r\n                head=head.next\r\n                end=head\r\n            elif end.next==None and head.val==end.val:\r\n                head.next=None\r\n                end=end.next\r\n            else:\r\n                return head0\r\n\r\n        return head0\r\n# @lc code=end<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image is-style-default\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-286.png\" alt=\"\" class=\"wp-image-2361\" width=\"393\" height=\"221\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-286.png 611w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-286-300x169.png 300w\" sizes=\"(max-width: 393px) 100vw, 393px\" \/><\/figure><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b58\u5728\u4e00\u4e2a\u6309\u5347\u5e8f\u6392\u5217\u7684\u94fe\u8868\uff0c\u7ed9\u4f60\u8fd9\u4e2a\u94fe\u8868\u7684\u5934\u8282\u70b9&nbsp;head&nbsp;\uff0c\u8bf7\u4f60\u5220\u9664\u6240\u6709\u91cd\u590d\u7684\u5143\u7d20\uff0c\u4f7f\u6bcf\u4e2a &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/01\/24\/leetcodeday83\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday83 &#8211;\u5220\u9664\u6392\u5e8f\u94fe\u8868\u4e2d\u7684\u91cd\u590d\u5143\u7d20<\/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\/2360"}],"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=2360"}],"version-history":[{"count":2,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2360\/revisions"}],"predecessor-version":[{"id":2363,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2360\/revisions\/2363"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=2360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=2360"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=2360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}