141-Linked-List-Cycle
Sat 17 May 2025
https://leetcode.com/problems/linked-list-cycle
import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
def hasCycle(self, head: ListNode) -> bool:
slow = head
fast = head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
if slow == fast:
return True
return False
new Solution().hasCycle()
Score: 5
Category: leetcode