struct Node {
int val;
Node *next;
Node(int x) : val(x), next(nullptr) {}
};
bool hasCycle(Node *head) {
if (!head || !head->next)
return false;
Node* slow = head;
Node* fast = head->next;
while (fast && fast->next) {
if (slow == fast) return true;
_______________________ // 在此填入代码
}
return false;
}