{"id":712,"date":"2020-06-23T23:56:28","date_gmt":"2020-06-23T15:56:28","guid":{"rendered":"http:\/\/www.guanhaobo.cn\/?p=712"},"modified":"2020-06-23T23:56:28","modified_gmt":"2020-06-23T15:56:28","slug":"jz15-%e5%8f%8d%e8%bd%ac%e9%93%be%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/www.guanhaobo.cn\/?p=712","title":{"rendered":"JZ15 \u2014 \u53cd\u8f6c\u94fe\u8868"},"content":{"rendered":"<h3>\u9898\u76ee\u63cf\u8ff0<\/h3>\n<p>\u8f93\u5165\u4e00\u4e2a\u94fe\u8868\uff0c\u53cd\u8f6c\u94fe\u8868\u540e\uff0c\u8f93\u51fa\u65b0\u94fe\u8868\u7684\u8868\u5934\u3002<\/p>\n<h3>\u9898\u76ee\u5206\u6790<\/h3>\n<p>\u8fd9\u4e2a\u9898\u76ee\u7684\u610f\u601d\u5176\u5b9e\u662f\u5728\u539f\u94fe\u8868\u4e0a\u76f4\u63a5\u8fdb\u884c\u53cd\u8f6c\u3002<br \/>\n\u5176\u5b9e\u4e5f\u5f88\u7b80\u5355\uff0c\u53ea\u8981\u7a0d\u5fae\u6ce8\u610f\u4e00\u4e0b\u4e34\u754c\u4f4d\u7f6e\u7684\u5904\u7406\u5373\u53ef\u3002<br \/>\n\u4e3b\u8981\u601d\u8def\uff1a<br \/>\n\u904d\u5386\u539f\u94fe\u8868<br \/>\n1. \u6267\u884c<code>pnext = pHead-&gt;next<\/code>\uff0c\u8bb0\u5f55\u5f53\u524d\u7ed3\u70b9<code>pHead<\/code>\u7684\u540e\u4e00\u4e2a\u7ed3\u70b9<code>*pnext<\/code><br \/>\n2. \u6267\u884c<code>pHead-&gt;next = pre<\/code>\uff0c\u5c06\u5f53\u524d\u7ed3\u70b9\u7684<code>next<\/code>\u6307\u5411\u524d\u4e00\u4e2a\u7ed3\u70b9\uff0c\u5b9e\u73b0\u53cd\u8f6c\u3002<br \/>\n3. \u5f53\u524d\u7ed3\u70b9\u5df2\u7ecf\u53cd\u8f6c\u5b8c\u6210\uff0c\u9700\u8981\u6307\u5411\u4e0b\u4e00\u4e2a\u7ed3\u70b9\u4e86\u3002\u9996\u5148\u6267\u884c<code>pre = pHead<\/code>\uff0c\u5c06\u5f53\u524d\u7ed3\u70b9\u8d4b\u503c\u7ed9<code>pre<\/code>\uff0c\u6210\u4e3a\u4e0b\u4e00\u4e2a\u7ed3\u70b9\u7684\u524d\u4e00\u4e2a\u7ed3\u70b9\u3002\u7136\u540e\u6267\u884c<code>pHead = pnext<\/code>\uff0c\u5c06<code>pHead<\/code>\u6307\u5411\u4e0b\u4e00\u4e2a\u7ed3\u70b9\u3002<\/p>\n<h3>C++<\/h3>\n<pre><code class=\"language-cpp line-numbers\">\/*\nstruct ListNode {\n    int val;\n    struct ListNode *next;\n    ListNode(int x) :\n            val(x), next(NULL) {\n    }\n};*\/\nclass Solution\n{\npublic:\n    ListNode *ReverseList(ListNode *pHead)\n    {\n        ListNode *pre = NULL, *pnext;\n        while (pHead)\n        {\n            pnext = pHead-&gt;next;\n            pHead-&gt;next = pre;\n            pre = pHead;\n            pHead = pnext;\n        }\n        return pre;\n    }\n};\n<\/code><\/pre>\n<h3>Java<\/h3>\n<pre><code class=\"language-java line-numbers\">\/*\npublic class ListNode {\n    int val;\n    ListNode next = null;\n\n    ListNode(int val) {\n        this.val = val;\n    }\n}*\/\npublic class Solution {\n    public ListNode ReverseList(ListNode head) {\n        ListNode pre = null, pnext;\n        while (head != null) {\n            pnext = head.next;\n            head.next = pre;\n            pre = head;\n            head = pnext;\n        }\n        return pre;\n    }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u63cf\u8ff0 \u8f93\u5165\u4e00\u4e2a\u94fe\u8868\uff0c\u53cd\u8f6c\u94fe\u8868\u540e\uff0c\u8f93\u51fa\u65b0\u94fe\u8868\u7684\u8868\u5934\u3002 \u9898\u76ee\u5206\u6790 \u8fd9\u4e2a\u9898\u76ee\u7684\u610f\u601d\u5176\u5b9e\u662f\u5728\u539f\u94fe\u8868\u4e0a\u76f4\u63a5\u8fdb\u884c\u53cd\u8f6c\u3002 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[39],"class_list":["post-712","post","type-post","status-publish","format-standard","hentry","category-algo","tag-offer"],"_links":{"self":[{"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=\/wp\/v2\/posts\/712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=712"}],"version-history":[{"count":0,"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=\/wp\/v2\/posts\/712\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guanhaobo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}