-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Description
Bug Report for https://neetcode.io/problems/linked-list-cycle-detection
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
The problem description mentions that the list has at least 1 node in it. However, one of the tests that the solution runs against has an empty list.
1 <= Length of the list <= 1000.
code that highlights the bug
class Solution:
def hasCycle(self, head: Optional[ListNode]) -> bool:
output = False
s, f = head, head.next.next if head.next else None
while f:
if s == f:
output = True
break
s = s.next
f = f.next.next if f.next else None
return output
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels