Linked List Cycle
Example 1:

Example 2:

Example 3:

Constraints:
My Solution
Last updated



Last updated
func hasCycle(head *ListNode) bool {
slow, fast := head, head
for fast != nil && fast.Next != nil {
fast = fast.Next.Next
slow = slow.Next
if fast == slow {
return true
}
}
return false
}