'''class Solution {
public:
ListNode *detectCycle(ListNode *head) {
if(head == NULL or head->next == NULL)
return NULL;
ListNode *slow = head, *fast = head;
int flag = 0;
while(fast and fast->next)
{
fast = fast->next->next;
slow = slow->next;
if(slow == fast)
{
break;
}
}
slow = head;
while(slow != fast)
{
slow = slow->next;
fast = fast->next;
}
return slow;

}

};'''

Can Anyone answer why this code is giving me error

Comments (0)