We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1025e06 commit 15a283cCopy full SHA for 15a283c
go/linked_list_cycle.go
@@ -3,10 +3,10 @@ package main
3
4
// `https://github.com/ryo-devz/LeetCode/pull/1#discussion_r1710718113`に書かれているとおり、印をつける方法はデメリットが大きい
5
func hasCycle(head *ListNode) bool {
6
- fast, slow := head, head
+ slow, fast := head, head
7
for fast != nil && fast.Next != nil {
8
- fast, slow = fast.Next.Next, slow.Next
9
- if fast == slow {
+ slow, fast = slow.Next, fast.Next.Next
+ if slow == fast {
10
return true
11
}
12
0 commit comments