【算法分析】如何理解快慢指针?判断linked list中是否有环、找到环的起始节点位置。以Leetcode 141. Linked List Cycle, 142. Linked List Cycle II 为例 | Python实现
引入
快慢指针经常用于链表(linked list)中环(Cycle)相关的问题。LeetCode中对应题目分别是:
- 141. Linked List Cycle 判断linked list中是否有环
- 142. Linked List Cycle II 找到环的起始节点(entry node)位置。