Detect a cycle in a linked list
Which technique detects a cycle in a linked list in extra space?
Show hints (2)+
- The constraint is space, so a hash set is out.
- Two pointers at different speeds will coincide inside a loop.
Answer
Reveal answer →Final answer
Floyd's fast/slow (tortoise-and-hare) pointers - space
Create a free account to see the full worked solution and track your progress.
Interview format: Hedge Fund Quant, Options Trading