How to find the length of a linked list that is having cycles in it?
- by Bragaadeesh
This was one of the interview questions asked. How to find the length of a linked list that is having cycle in it. I know how to calculate whether a linked list has a cycle or not using Hare and Tortoise technique. I even know how to calculate the length by storing the addresses in a hashset.
But what I was not able to tell is how to calculate the length of the linked list without using a external space of O(n). Please help me. Thanks.