no142专题

leetcode No142. Linked List Cycle II

Question: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Algorithm: 首先fast每次走两步,slow每次走1步,如果fast走到NULL,说明没有环,如果fast和slow相遇,说明有环,假设fast和slow在Z