input: Write a python function to detect a cycle in a linked list.
  assert detect_cycle(ListNode(1))==False
  node1, node2, node3 = ListNode(1), ListNode(2), ListNode(3)
  node1.next, node2.next, node3.next = node2, node3, node1
  assert detect_cycle(node1)==True
  node4, node5, node6 = ListNode(4), ListNode(5), ListNode(6)
  node4.next, node5.next = node5, node6
  assert detect_cycle(node4)==False
output: class ListNode:
      def __init__(self, val=0, next=None):
          self.val = val
          self.next = next
  
  def detect_cycle(head: ListNode) -> bool:
      slow, fast = head, head
      while fast and fast.next:
          slow = slow.next
          fast = fast.next.next
          if slow == fast:
              return True
      return False