Test for cyclicity

#1

[EPIJ v 1.6.1 problem 8.3]

I have a solution that detects the presence of a cycle. Is it possible to find the start node of the cycle in better than O(n) space?

0 Likes

#2

Hint: You can try to use the solution of overlapping list.

0 Likes

#3

:slight_smile: is that a “yes” to my question?
Can it be done in O(1) space?
Also, does the problem allow for being destructive of the list, in order to find the start node of the cycle?
For instance, would it be allowed for me to break the cycle?

1 Like

#4

Never mind. I have a solution now. For others with the same question: Yes, it’s possible to find the start node of the cycle in O(1) space and without modifying the list.

0 Likes