```
class Solution {
public:
bool checkCycle(ListNode* head) {
if (head == NULL)
return false;
ListNode *p1 = head, *p2 = head;
while (p1 != NULL && p2 != NULL && p2->next != NULL) {
p1 = p1->next;
p2 = p2->next->next;
if (p1 == p2)
break;
}
if (p1 == NULL || p2 == NULL || p2->next == NULL) {
return false;
}
return true;
}
ListNode *detectCycle(ListNode *head) {
if (!checkCycle(head))
return NULL;
ListNode* p = head;
while (p->next != NULL) {
ListNode* tmp = p->next;
p->next = NULL;
p = tmp;
}
return p;
}
};
```

This is my code but the result is :

```
Input: {3,2,0,-4}, tail connects to node index 1
Output: output node is not in the linked list
Expected: tail connects to node index 1
```

However, it performs well in visual studio 2010. I really don't know what the meaning of "not in the linked list" is!