Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- bool hasCycle(ListNode *head) {
- ListNode *t1 = head, *t2 = head;
- do
- {
- if (t2 == NULL || t2->next == NULL)
- return 0;
- t1 = t1->next;
- t2 = t2->next->next;
- } while (t1 != t2);
- return 1;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment