解題說明
C++ 解法
複雜度分析
虛擬碼
1. Initialize slow = head, fast = head
2. Phase 1 - detect cycle:
While fast and fast.next are not null:
slow = slow.next
fast = fast.next.next
If slow == fast: break (cycle found)
3. If no cycle detected, return null
4. Phase 2 - find entrance:
Set ptr = head
While ptr != slow:
ptr = ptr.next
slow = slow.next
5. Return ptr (cycle entrance)