{"id":5200,"date":"2023-11-17T13:45:00","date_gmt":"2023-11-17T05:45:00","guid":{"rendered":"https:\/\/white-night.club\/?p=5200"},"modified":"2023-11-17T13:47:51","modified_gmt":"2023-11-17T05:47:51","slug":"ad152","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/11\/17\/ad152\/","title":{"rendered":"141.\u00a0\u73af\u5f62\u94fe\u8868"},"content":{"rendered":"\n<p>\u7ed9\u4f60\u4e00\u4e2a\u94fe\u8868\u7684\u5934\u8282\u70b9\u00a0<code>head<\/code>\u00a0\uff0c\u5224\u65ad\u94fe\u8868\u4e2d\u662f\u5426\u6709\u73af\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u94fe\u8868\u4e2d\u6709\u67d0\u4e2a\u8282\u70b9\uff0c\u53ef\u4ee5\u901a\u8fc7\u8fde\u7eed\u8ddf\u8e2a&nbsp;<code>next<\/code>&nbsp;\u6307\u9488\u518d\u6b21\u5230\u8fbe\uff0c\u5219\u94fe\u8868\u4e2d\u5b58\u5728\u73af\u3002 \u4e3a\u4e86\u8868\u793a\u7ed9\u5b9a\u94fe\u8868\u4e2d\u7684\u73af\uff0c\u8bc4\u6d4b\u7cfb\u7edf\u5185\u90e8\u4f7f\u7528\u6574\u6570&nbsp;<code>pos<\/code>&nbsp;\u6765\u8868\u793a\u94fe\u8868\u5c3e\u8fde\u63a5\u5230\u94fe\u8868\u4e2d\u7684\u4f4d\u7f6e\uff08\u7d22\u5f15\u4ece 0 \u5f00\u59cb\uff09\u3002<strong>\u6ce8\u610f\uff1a<code>pos<\/code>&nbsp;\u4e0d\u4f5c\u4e3a\u53c2\u6570\u8fdb\u884c\u4f20\u9012&nbsp;<\/strong>\u3002\u4ec5\u4ec5\u662f\u4e3a\u4e86\u6807\u8bc6\u94fe\u8868\u7684\u5b9e\u9645\u60c5\u51b5\u3002<\/p>\n\n\n\n<p><em>\u5982\u679c\u94fe\u8868\u4e2d\u5b58\u5728\u73af<\/em>&nbsp;\uff0c\u5219\u8fd4\u56de&nbsp;<code>true<\/code>&nbsp;\u3002 \u5426\u5219\uff0c\u8fd4\u56de&nbsp;<code>false<\/code>&nbsp;\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image has-custom-border\"><img decoding=\"async\" src=\"https:\/\/assets.leetcode-cn.com\/aliyun-lc-upload\/uploads\/2018\/12\/07\/circularlinkedlist.png\" alt=\"\" style=\"border-style:none;border-width:0px;border-radius:0px\"\/><\/figure>\n\n\n\n<p><strong>\u8f93\u5165\uff1a<\/strong>head = [3,2,0,-4], pos = 1 <strong>\u8f93\u51fa\uff1a<\/strong>true <strong>\u89e3\u91ca\uff1a<\/strong>\u94fe\u8868\u4e2d\u6709\u4e00\u4e2a\u73af\uff0c\u5176\u5c3e\u90e8\u8fde\u63a5\u5230\u7b2c\u4e8c\u4e2a\u8282\u70b9\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b&nbsp;2\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image has-custom-border\"><img decoding=\"async\" src=\"https:\/\/assets.leetcode-cn.com\/aliyun-lc-upload\/uploads\/2018\/12\/07\/circularlinkedlist_test2.png\" alt=\"\" style=\"border-style:none;border-width:0px;border-radius:0px\"\/><\/figure>\n\n\n\n<p><strong>\u8f93\u5165\uff1a<\/strong>head = [1,2], pos = 0 <strong>\u8f93\u51fa\uff1a<\/strong>true <strong>\u89e3\u91ca\uff1a<\/strong>\u94fe\u8868\u4e2d\u6709\u4e00\u4e2a\u73af\uff0c\u5176\u5c3e\u90e8\u8fde\u63a5\u5230\u7b2c\u4e00\u4e2a\u8282\u70b9\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 3\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image has-custom-border\"><img decoding=\"async\" src=\"https:\/\/assets.leetcode-cn.com\/aliyun-lc-upload\/uploads\/2018\/12\/07\/circularlinkedlist_test3.png\" alt=\"\" style=\"border-style:none;border-width:0px;border-radius:0px\"\/><\/figure>\n\n\n\n<p><strong>\u8f93\u5165\uff1a<\/strong>head = [1], pos = -1 <strong>\u8f93\u51fa\uff1a<\/strong>false <strong>\u89e3\u91ca\uff1a<\/strong>\u94fe\u8868\u4e2d\u6ca1\u6709\u73af\u3002<\/p>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li>\u94fe\u8868\u4e2d\u8282\u70b9\u7684\u6570\u76ee\u8303\u56f4\u662f&nbsp;<code>[0, 10<sup>4<\/sup>]<\/code><\/li>\n\n\n\n<li><code>-10<sup>5<\/sup> &lt;= Node.val &lt;= 10<sup>5<\/sup><\/code><\/li>\n\n\n\n<li><code>pos<\/code>&nbsp;\u4e3a&nbsp;<code>-1<\/code>&nbsp;\u6216\u8005\u94fe\u8868\u4e2d\u7684\u4e00\u4e2a&nbsp;<strong>\u6709\u6548\u7d22\u5f15<\/strong>&nbsp;\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u8fdb\u9636\uff1a<\/strong>\u4f60\u80fd\u7528&nbsp;<code>O(1)<\/code>\uff08\u5373\uff0c\u5e38\u91cf\uff09\u5185\u5b58\u89e3\u51b3\u6b64\u95ee\u9898\u5417\uff1f<\/p>\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 has-link-color wp-elements-8102044ba850e1116fa4bc5ca3946389\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>\u5feb\u6162\u6307\u9488<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u5feb\u6307\u9488\u6bcf\u6b21\u8d70\u4e24\u6b65\uff0c\u6162\u6307\u9488\u6bcf\u6b21\u4e2d\u4e00\u6b65\u3002\u5982\u679c\u94fe\u8868\u4e2d\u5b58\u5728\u73af\u7684\u8bdd\uff0c\u90a3\u4e48\u5feb\u6307\u9488\u4e00\u5b9a\u4f1a\u5728\u67d0\u4e2a\u65f6\u523b\u4e0e\u6162\u6307\u9488\u76f8\u7b49\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\r\n * Definition for singly-linked list.\r\n * type ListNode struct {\r\n *     Val int\r\n *     Next *ListNode\r\n * }\r\n *\/\r\nfunc hasCycle(head *ListNode) bool {\r\n    if head==nil||head.Next==nil{\r\n        return false\r\n    }\r\n    slow,fast:=head,head.Next\r\n    for slow!=fast{\r\n        if(fast==nil||fast.Next==nil){\r\n            return false\r\n        }\r\n        slow=slow.Next\r\n        fast=fast.Next.Next\r\n    }\r\n    return true\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u73af\u5f62\u94fe\u8868<\/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\/5200"}],"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=5200"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/5200\/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=5200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=5200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=5200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}