Skip to content

Commit

Permalink
re-solve "141. Linked List Cycle"
Browse files Browse the repository at this point in the history
  • Loading branch information
lancelote committed Oct 26, 2024
1 parent 6d5259d commit 3b1db92
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/linked_list_cycle.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from src.utils.linked_list import ListNode
from utils.linked_list import ListNode


class Solution:
def hasCycle(self, head: ListNode | None) -> bool:
slow = fast = head
slow = head
fast = head

while slow and fast and fast.next and fast.next.next:
while slow and fast and fast.next:
slow = slow.next
fast = fast.next.next

Expand Down

0 comments on commit 3b1db92

Please sign in to comment.