/**
- Definition for singly-linked list.
- type ListNode struct {
-
Val int -
Next *ListNode - }
*/
func hasCycle(head *ListNode) bool {
hash := make(map[*ListNode]int)
for head !=nil{
if _,ok :=hash[head];ok{
return true
}
hash[head]=head.Val
head = head.Next
}
return false
}
2442

被折叠的 条评论
为什么被折叠?



