赞
踩
class Solution {
public:
bool hasCycle(ListNode *head) {
struct ListNode* slow,*fast=head;
while(fast && fast->next) {
slow=slow->next;
fast=fast->next->next;
if(slow ==fast) {
return true;
}
}
return false;
}
};
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。