bool (struct ListNode *head) { if (head == NULL || head->next == NULL) { return false; } struct ListNode * fast = head->next, * slow = head; while (slow != fast) { if (fast == NULL || fast->next == NULL) { return false; } slow = slow->next; fast = fast->next->next; } return true; }
|
近期评论