题解 | #判断链表中是否有环#
判断链表中是否有环
http://www.nowcoder.com/practice/650474f313294468a4ded3ce0f7898b9
package main
import . "nc_tools"
//双指针法
func hasCycle( head *ListNode ) bool {
// write code here
fast, slow := head, head
for fast != nil && fast.Next != nil {
fast = fast.Next.Next
slow = slow.Next
if fast == slow {
return true
}
}
return false
}
平安产险科技中心工作强度 22人发布