Skip to content

Commit dfb3101

Browse files
authored
Create Linked List Cycle.py
1 parent 1a54a53 commit dfb3101

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

easy/Linked List Cycle.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#141. Linked List Cycle
2+
class Solution:
3+
def hasCycle(self, head: ListNode) -> bool:
4+
slow = head
5+
fast = head
6+
7+
while fast and fast.next:
8+
slow = slow.next
9+
fast = fast.next.next
10+
if slow == fast:
11+
return True
12+
13+
return False

0 commit comments

Comments
 (0)