You can make your 'Find the start of cycle' proof simpler if you don't use meeting point.
Let second pointer start not at the 'meeting point', but M
steps ahead of first pointer. (Where M
is the length of the loop.)
This way, proof is pretty obvious. When the first pointer reaches start of the loop, second will be exactly M
steps ahead: also at the start of the loop.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…