# [Linked List Cycle]: input {1,2}, no circle? What does mean?

• Input: {1,2}, no cycle
Output: true
Expected: false

I do not understand how {1,2} can be a input
Isn't the input is a structure?

class Solution {
public:
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
}
};

• I found the answer myself.
{1,2} denotes two different nodes. There is no circle here.
If input is {1,2,3,2}, means there is a circle {2,3,2}.

• Could you please format your tags? `-` is use for combining words, space will treat as tag separator. I think your tag should be `linked-list-cycle` and `input`.

• Hi wshaoxuan, actually I am not quite agree with your idea.
linked list cycle is not identify by its value, is up to ".next".
Check out the data structure again:

``````class ListNode {
int val;
ListNode next;
ListNode(int x) {
val = x;
next = null;
}
}
``````

for your example {1,2,3,2}, this is not a linked list cycle, 1,2,3,2 are only the values.
the structure is like 1->2->3->2->null. If "next" of the last node which value is "2" point to the the second node, this means there is a cycle, otherwise, there is no cycle in the linked list.

1. no cycle

1----->2----->NULL

1. has cycle

1----->2------>1 [the address of first '1' is the same with the second '1']

• Well, Input is a structure but instead of representing the link list like as follows

a -> b -> c->NULL.

OJ is showing you like {a,b,c}, so you can assume that {1,2} is equivalent to 1->2->NULL.

• This post is deleted!

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.