Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 46c3ab2

Browse files
committed
update:141
1 parent 9e9b984 commit 46c3ab2

File tree

1 file changed

+2
-4
lines changed
  • problems/0141.linked-list-cycle

1 file changed

+2
-4
lines changed

‎problems/0141.linked-list-cycle/run.go‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@ func hasCycle(head *structure.ListNode) bool {
1515
if head == nil || head.Next == nil {
1616
return false
1717
}
18-
1918
slow := head
2019
fast := head
2120
for fast != nil && fast.Next != nil {
21+
slow = slow.Next
22+
fast = fast.Next.Next
2223
if slow == fast {
23-
// if slow.Val == fast.Val { // 模拟测试
2424
return true
2525
}
26-
slow = slow.Next
27-
fast = fast.Next.Next
2826
}
2927
return false
3028
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /