text: # Author: Melissa Perez
  # Date: --/--/--
  # Description:
  # Definition for singly-linked list.
  # class ListNode:
  #     def __init__(self, x):
  #         self.val = x
  #         self.next = None
  
  class Solution:
      def hasCycle(self, head: ListNode) -> bool:
          slow = head
  
          if slow is None:
              return False
  
          fast = head.next
  
          while slow != fast:
              if fast is None or fast.next is None:
                  return False
              slow = slow.next
              fast = fast.next.next
  
          return True
  