Linked List Cycle
class Solution { public: bool hasCycle(ListNode *head) { if(!head) return NULL; ListNode* fast=head; ListNode* slow=head; while(fast->next&&fast->next->next) { slow=slow->next; fast=fast->next->next; if(slow==fast) return true; } return false; } };