Given the head of a singly linked list, determine whether the list contains a cycle. A cycle exists if a node can be reached again by continuously following next pointers.
Return True if the linked list has a cycle, otherwise return False.
head, the head node of a singly linked list. Each node has fields val and next.You must solve the problem without modifying the linked list structure.
def has_cycle(head):