complexitydsalinked-lists
A linked-list cycle check can use two speeds
Anonymous
move one pointer one step at a time and another two steps at a time. If a cycle exists, they eventually meet; if the faster pointer reaches null, there is no cycle. This takes O(n) time and O(1) extra space. Compare node identity, not stored values.
0