Skip to content

Commit 6f574b1

Browse files
Solve : Linked List Cycle
1 parent 15a60ed commit 6f574b1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution:
2+
def hasCycle(self, head):
3+
slow = fast = head
4+
while fast and fast.next:
5+
slow = slow.next
6+
fast = fast.next.next
7+
if slow == fast:
8+
return True
9+
return False

0 commit comments

Comments
 (0)