mirror of
https://github.com/chefyuan/algorithm-base.git
synced 2025-08-04 15:01:35 +00:00
添加Go语言题解
This commit is contained in:
@@ -124,3 +124,22 @@ class Solution {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Go Code:
|
||||
|
||||
```go
|
||||
func hasCycle(head *ListNode) bool {
|
||||
if head == nil { return false }
|
||||
s, f := head, head
|
||||
for f != nil && f.Next != nil {
|
||||
s = s.Next
|
||||
f = f.Next.Next
|
||||
if s == f {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user