题解 | #链表中环的入口结点#
链表中环的入口结点
https://www.nowcoder.com/practice/253d2c59ec3e4bc68da16833f79a38e4
package main func EntryNodeOfLoop(pHead *ListNode) *ListNode { p := pHead q := pHead for p != nil && q != nil { p = p.Next q = q.Next if q != nil { q = q.Next } if p == q { break } } p = pHead for p != nil && q != nil { if p == q { return q } p = p.Next q = q.Next } return nil }