Skip to content

Commit c84b516

Browse files
committed
141 update
1 parent c391db2 commit c84b516

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

linkedlist/LinkedListCycle.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Definition for singly-linked list.
2+
# class ListNode(object):
3+
# def __init__(self, x):
4+
# self.val = x
5+
# self.next = None
6+
7+
class Solution(object):
8+
def hasCycle(self, head):
9+
slow = fast = head
10+
11+
while fast and fast.next:
12+
slow = slow.next
13+
fast = fast.next.next
14+
if slow == fast:
15+
return True
16+
return False

0 commit comments

Comments
 (0)