You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To represent a cycle in the given linked list, we use an integer `pos` which represents the position (0-indexed) in the linked list where tail connects to. If `pos` is `-1`, then there is no cycle in the linked list.
10
-
11
-
12
-
*Example 1:*
13
-
14
-
[subs="verbatim,quotes,macros"]
15
-
----
16
-
*Input:* head = [3,2,0,-4], pos = 1
17
-
*Output:* true
18
-
*Explanation:* There is a cycle in the linked list, where tail connects to the second node.
19
-
----
10
+
_如果链表中存在环_ ,则返回 `true` 。 否则,返回 `false` 。
20
11
21
12
13
+
*示例 1:*
22
14
23
15
image::images/0141-00.png[{image_attr}]
24
16
25
-
*Example 2:*
26
-
27
-
[subs="verbatim,quotes,macros"]
28
-
----
29
-
*Input:* head = [1,2], pos = 0
30
-
*Output:* true
31
-
*Explanation:* There is a cycle in the linked list, where tail connects to the first node.
32
-
----
33
-
17
+
....
18
+
输入:head = [3,2,0,-4], pos = 1
19
+
输出:true
20
+
解释:链表中有一个环,其尾部连接到第二个节点。
21
+
....
34
22
23
+
*示例 2:*
35
24
36
25
image::images/0141-01.png[{image_attr}]
37
26
38
-
*Example 3:*
39
-
40
-
[subs="verbatim,quotes,macros"]
41
-
----
42
-
*Input:* head = [1], pos = -1
43
-
*Output:* false
44
-
*Explanation:* There is no cycle in the linked list.
45
-
----
27
+
....
28
+
输入:head = [1,2], pos = 0
29
+
输出:true
30
+
解释:链表中有一个环,其尾部连接到第一个节点。
31
+
....
46
32
33
+
*示例 3:*
47
34
48
35
image::images/0141-03.png[{image_attr}]
49
36
37
+
....
38
+
输入:head = [1], pos = -1
39
+
输出:false
40
+
解释:链表中没有环。
41
+
....
42
+
43
+
*提示:*
50
44
51
-
*Follow up:*
45
+
* 链表中节点的数目范围是 `+[0, 10+`^`+4+`^`+]+`
46
+
* `+-10+`^`+5+`^`+<= Node.val <= 10+`^`+5+`^
47
+
* `+pos+` 为 `+-1+` 或者链表中的一个 *有效索引* 。
52
48
53
-
Can you solve it using _O(1)_ (i.e. constant) memory?
0 commit comments