{"id":1781,"date":"2016-02-07T12:21:24","date_gmt":"2016-02-07T04:21:24","guid":{"rendered":"http:\/\/boweihe.me\/?p=1781"},"modified":"2016-02-07T12:21:24","modified_gmt":"2016-02-07T04:21:24","slug":"leetcode-237-delete-node-in-a-linked-list","status":"publish","type":"post","link":"https:\/\/dayandcarrot.space\/?p=1781","title":{"rendered":"LeetCode #237. Delete Node in a Linked List"},"content":{"rendered":"<p><strong>\u9898\u76ee\uff1a<\/strong><a href=\"https:\/\/leetcode.com\/problems\/delete-node-in-a-linked-list\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/leetcode.com\/problems\/delete-node-in-a-linked-list\/<\/a><br \/>\n<strong>\u601d\u8def\uff1a<\/strong><br \/>\n\u56e0\u4e3a\u53ea\u7ed9\u8981\u5220\u53bb\u8282\u70b9\u7684\u6307\u9488\uff0c\u6240\u4ee5\u5c31\u8981\u60f3\u70b9\u6b6a\u529e\u6cd5\u3002<br \/>\n\u5047\u8bbe\u6211\u4eec\u6709\u8282\u70b91,2,3,\u30104\u3011,5,6\uff0c\u8981\u5220\u53bb4\u8fd9\u4e2a\u70b9\uff0c\u90a3\u5176\u5b9e\u53ea\u8981\u628a\u540e\u5e8f\u8282\u70b95\u7684\u503c\u590d\u5236\u7ed94\uff0c\u7136\u540e\u6211\u4eec\u53ef\u4ee5\u628a\u540e\u9762\u539f\u6765\u90a3\u4e2a5\u5220\u6389\uff0c\u628a\u539f\u6709\u76844\u8282\u70b9\u94fe\u52306\u5c31\u884c\u4e86~\u5927\u81f4\u610f\u601d\u5c31\u662f\uff0c\u901a\u8fc7\u5f80\u524d\u590d\u5236\u4e00\u4e2a\u503c\uff0c\u6784\u9020\u51fa\u4e00\u4e2a\u65b0\u7684\u201c4\u201d\u7684\u524d\u5e8f\u8282\u70b9\u3002<\/p>\n<pre class=\"lang:default decode:true \">\u4f7f\u7528\u524d\uff1a1,2,3,[4],5,6\n\u62f7\u8d1d\u503c\uff1a1,2,3,5,[5],6\n\u5220\u53bb\u591a\u4e8e\u8282\u70b9(\u5c06\u65b0\u76845\u8282\u70b9\u94fe\u63a5\u5230\u62f7\u8d1d\u76845\u53f3\u8fb9\u76846\uff0c\u5220\u53bb\u8001\u76845\u8282\u70b9)\uff1a1,2,3,5,6<\/pre>\n<p><strong>\u4ee3\u7801\uff1a<\/strong><\/p>\n<pre class=\"lang:c++ decode:true \">\/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     ListNode *next;\n *     ListNode(int x) : val(x), next(NULL) {}\n * };\n *\/\nclass Solution {\npublic:\n    void deleteNode(ListNode* node) {\n        ListNode* nextNode = node-&gt;next;\n        node-&gt;val = nextNode-&gt;val; \/\/Copy value\n        ListNode* thirdNode = nextNode-&gt;next;\n        node-&gt;next = thirdNode;\n        delete nextNode;\n    }\n};<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\uff1ahttps:\/\/leetcode.com\/problems\/delete-node-in-a-linked-list\/ \u601d\u8def\uff1a \u56e0\u4e3a\u53ea\u7ed9\u8981\u5220\u53bb\u8282\u70b9\u7684\u6307\u9488\uff0c\u6240\u4ee5\u5c31\u8981\u60f3\u70b9\u6b6a\u529e\u6cd5\u3002 \u5047\u8bbe\u6211\u4eec\u6709\u8282\u70b91,2,3,\u30104\u3011,5,6\uff0c\u8981\u5220\u53bb4\u8fd9\u4e2a\u70b9\uff0c\u90a3\u5176\u5b9e\u53ea\u8981\u628a\u540e\u5e8f\u8282\u70b95\u7684\u503c\u590d\u5236\u7ed94\uff0c\u7136\u540e\u6211\u4eec\u53ef\u4ee5\u628a\u540e\u9762\u539f\u6765\u90a3\u4e2a5\u5220\u6389\uff0c\u628a\u539f\u6709\u76844\u8282\u70b9\u94fe\u52306\u5c31\u884c\u4e86~\u5927\u81f4\u610f\u601d\u5c31\u662f\uff0c\u901a\u8fc7\u5f80\u524d\u590d\u5236\u4e00\u4e2a\u503c\uff0c\u6784\u9020\u51fa\u4e00\u4e2a\u65b0\u7684\u201c4\u201d\u7684\u524d\u5e8f\u8282\u70b9\u3002 \u4f7f\u7528\u524d\uff1a1,2,3,[4],5,6 \u62f7\u8d1d\u503c\uff1a1,2,3,5,[5],6 \u5220\u53bb\u591a\u4e8e\u8282\u70b9(\u5c06\u65b0\u76845\u8282\u70b9\u94fe\u63a5\u5230\u62f7\u8d1d\u76845\u53f3\u8fb9\u76846\uff0c\u5220\u53bb\u8001\u76845\u8282\u70b9)\uff1a1,2,3,5,6 \u4ee3\u7801\uff1a \/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *\/ class Solution { public: void deleteNode(ListNode* node) { ListNode* nextNode = node-&gt;next; node-&gt;val = nextNode-&gt;val; \/\/Copy value ListNode* thirdNode = nextNode-&gt;next; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[66],"class_list":["post-1781","post","type-post","status-publish","format-standard","hentry","category-study","tag-leetcode-oj"],"_links":{"self":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1781","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1781"}],"version-history":[{"count":0,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1781\/revisions"}],"wp:attachment":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1781"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1781"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1781"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}