Question DSA-LL-0010
MediumHow does Floyd's algorithm detect a cycle in a linked list?
- A.
A fast and a slow pointer will meet if and only if there is a cycle
- B.
By reversing the list
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Linked Lists question
How does Floyd's algorithm detect a cycle in a linked list?
A fast and a slow pointer will meet if and only if there is a cycle
By reversing the list
Sign up free to see the answer and a step-by-step explanation.
By counting the nodes
By marking every node as visited in a hash set