Skip to content

Commit c01015a

Browse files
committed
minor fix
1 parent 30bb187 commit c01015a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

data_structure/linked_list.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,12 @@ class Solution:
314314
```Python
315315
class Solution:
316316
def hasCycle(self, head: ListNode) -> bool:
317-
318317
slow = fast = head
319318

320-
while fast is not None and fast.next is not None:
319+
while fast and fast.next:
321320
# 只要需要访问.next,都必须先check是否为空。这就是while fast的用途。
322321
slow = slow.next
323-
fast = fast.next.next
322+
fast = fast.next.next
324323
if fast == slow:
325324
return True
326325

0 commit comments

Comments
 (0)