class Solution {
public:
bool hasCycle(ListNode *head) {
ListNode* fastnode;
ListNode* slownode;
if(head){
fastnode = head;
slownode = head;
} else return false;
while(fastnode->next != NULL && fastnode->next->next){
fastnode = fastnode->next->next;
slownode = slownode->next;
if(fastnode == slownode) return true;
}
return false;
}
};



