https://leetcode.cn/problems/linked-list-cycle-ii/
    需要注意的点
    1. 环头节点(环头),链表的头节点(链头),fast 跟slow 相遇的节点(相遇点)
    走n圈,环头到链头为a,slow 到相遇点为b, fast 在环里面走c,
    环的长度是b+c
    fast走过的距离是
    fast = a + n(b+c)+b = a + (n+1)b+nc
    slow走过的距离是
    slow = a+b
    等式
    a + (n+1)b+nc = 2(a+b)
    == a = c + (n-1)(b+c)

    1. # Definition for singly-linked list.
    2. # class ListNode:
    3. # def __init__(self, x):
    4. # self.val = x
    5. # self.next = None
    6. class Solution:
    7. def detectCycle(self, head: ListNode) -> ListNode:
    8. '''
    9. 环头节点(环头),链表的头节点(链头),fast 跟slow 相遇的节点(相遇点)
    10. 走n圈,环头到链头为a,slow 到相遇点为b, fast 在环里面走c,
    11. 环的长度是b+c
    12. fast走过的距离是
    13. fast = a + n(b+c)+b = a + (n+1)b+nc
    14. slow走过的距离是
    15. slow = a+b
    16. 等式
    17. a + (n+1)b+nc = 2(a+b)
    18. == a = c + (n-1)(b+c)
    19. '''
    20. slow = head
    21. fast = head
    22. while fast and fast.next:
    23. fast = fast.next.next
    24. slow = slow.next
    25. if fast == slow:
    26. a = fast
    27. b = head
    28. while a != b:
    29. a = a.next
    30. b = b.next
    31. return a
    32. return None