leetcode/104-240525-pass/main.py
2024-05-25 12:08:06 +02:00

10 lines
297 B
Python

class Solution:
def hasCycle(self, head: Optional[ListNode]) -> bool:
cnt = 0
if head == None: return False
while cnt < 1e4+10:
if head.next == None:
return False
head = head.next
cnt += 1
return True