eolymp
bolt
Try our new interface for solving problems
Məsələlər

LinkedList Dövr

dərc olunub 25.06.22 15:52:08

int hasCycle(ListNode head) { if(head==NULL) return 0; ListNode p=head; ListNode* q=head; while(q->next && q->next->next){ p=p->next; q=q->next->next; if(p==q) return 1;
} return 0; }

dərc olunub 03.04.24 02:42:07

int hasCycle(ListNode head) { if (head == NULL) return 0; ListNode p = head; ListNode* q = head; while (q->next && q->next->next) { p = p->next; q = q->next->next; if (p == q) return 1; } return 0; }