Skip to content

Commit

Permalink
#20: add solution for exercise #141 in rust
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielvictorcf authored and gosiqueira committed Nov 1, 2022
1 parent f79c6e3 commit 3244dd7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions rust/linked-lists/0141-linked-list-cycle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from structures import ListNode

def hasCycle(head: ListNode) -> bool:
fast = head
slow = head

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

if fast == slow:
return True

return False

0 comments on commit 3244dd7

Please sign in to comment.