#leetcode题
class Solution:
def hasCycle(self, head: ListNode) -> bool:
p=head
if not p or not p.next or not p.next.next :
return False
while(p and p.next):
p=p.next.next
if p==head:
return True
else:
head=head.next
return False
#使用快慢指针,如果指针重合则说明有环