If you want to check if your linked list is circular you can use Floyd’s Cycle-Finding Algorithm aka Tortoise and the Hare Algorithm
.
It’s quite efficient as It has O(n) complexity.
Continue reading
If you want to check if your linked list is circular you can use Floyd’s Cycle-Finding Algorithm aka Tortoise and the Hare Algorithm
.
It’s quite efficient as It has O(n) complexity.
Continue reading